Skip to content

Commit 0c3f176

Browse files
committed
Add version & build date to the build process.
1 parent c61e54c commit 0c3f176

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

dev/src/docs/sidebar_content.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,13 @@ home.kids = [
7676
{
7777
label: "Help",
7878
id: "help",
79-
desc: "Help for the RegExr v3.5 application. See the <b>RegEx Reference</b> for help with Regular Expressions.",
79+
desc: "Help for the RegExr application. See the <b>RegEx Reference</b> for help with Regular Expressions.",
8080
kids: [
8181

8282
{
8383
label:"About",
84-
desc:"Created by <a href='http://twitter.com/gskinner/' target='_blank'>Grant Skinner</a> and the <a href='http://gskinner.com/' target='_blank'>gskinner</a> team, using the <a href='http://createjs.com/' target='_blank'>CreateJS</a> & <a href='http://codemirror.net/' target='_blank'>CodeMirror</a> libraries."+
84+
desc:"RegExr v[build-version], built on [build-date]."+
85+
"<p>Created by <a href='http://twitter.com/gskinner/' target='_blank'>Grant Skinner</a> and the <a href='http://gskinner.com/' target='_blank'>gskinner</a> team, using the <a href='http://createjs.com/' target='_blank'>CreateJS</a> & <a href='http://codemirror.net/' target='_blank'>CodeMirror</a> libraries.</p>"+
8586
"<p>You can provide feedback or log bugs on <a href='http://github.com/gskinner/regexr/' target='_blank'>GitHub</a>.</p>"
8687
},
8788
{

gulpfile.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ var del = require('del');
1919
var runSequence = require('run-sequence');
2020
var htmlmin = require('gulp-htmlmin');
2121

22+
var buildVersion = null;
23+
2224
gulp.task("default", ["browser-sync", "build-default", "watch"]);
2325
gulp.task("build-default", ["build-js", "build-sass"], browserSync.reload);
2426

@@ -30,7 +32,8 @@ gulp.task("build", function(cb) {
3032
});
3133

3234
gulp.task("deploy", function(cb) {
33-
runSequence("build", "clean-build", "copy-build", "inject-file-versions", "minify-html", cb);
35+
buildVersion = getBuildVersion();
36+
runSequence("build", "clean-build", "copy-build", "inject-build-version", "inject-file-versions", "minify-html", cb);
3437
});
3538

3639
gulp.task("browser-sync", function() {
@@ -114,7 +117,6 @@ gulp.task("inject", function() {
114117
.pipe(inject(gulp.src("dev/inject/*"), {
115118
transform: function(path, file) {
116119
var tag = /\.css$/ig.test(path) ? "style" : "";
117-
console.log(path, tag);
118120
return (tag ? "<"+tag+">" : "") + file.contents.toString() + (tag ? "</"+tag+">" : "");
119121
}
120122
}))
@@ -133,6 +135,14 @@ gulp.task("inject-file-versions", function(cb) {
133135
fs.writeFile("build/index.html", indexFile, cb);
134136
});
135137

138+
gulp.task("inject-build-version", function(cb) {
139+
var js = fs.readFileSync("deploy/regexr.js", "utf-8");
140+
js = js.replace("[build-version]", buildVersion);
141+
js = js.replace("[build-date]", getDateString());
142+
fs.writeFile("deploy/regexr.js", js, cb);
143+
});
144+
145+
136146
gulp.task("minify-html", function() {
137147
return gulp.src("build/index.html")
138148
.pipe(htmlmin({collapseWhitespace: true, conservativeCollapse: true, removeComments: true}))
@@ -178,3 +188,18 @@ function swallowError(err) {
178188
console.warn(err.toString());
179189
this.emit("end");
180190
}
191+
192+
function getBuildVersion() {
193+
let i = process.argv.indexOf("--v")
194+
let v = i === -1 ? null : process.argv[i+1];
195+
if (!v || !/^\d+\.\d+\.\d+/.test(v)) {
196+
throw("You must specify a version number with `--v x.x.x`.")
197+
}
198+
return v;
199+
}
200+
201+
function getDateString() {
202+
var now = new Date();
203+
var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
204+
return months[now.getMonth()]+" "+now.getDate()+", "+now.getFullYear();
205+
}

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ <h1 class="label">Menu</h1>
9595
RegExr is an online tool to <b>learn</b>, <b>build</b>, &amp; <b>test</b> Regular Expressions (RegEx / RegExp).
9696
<hr>
9797
<ul>
98-
<li>Results update in <b>real-time</b> as you type.</li>
9998
<li>Supports <b>JavaScript</b> &amp; <b>PHP/PCRE</b> RegEx.</li>
99+
<li>Results update in <b>real-time</b> as you type.</li>
100100
<li><b>Roll over</b> a match or expression for details.</li>
101101
<li><b>Save</b> &amp; share expressions with others.</li>
102102
<li>Use <b>Tools</b> to explore your results.</li>
@@ -171,7 +171,7 @@ <h1>Text</h1>
171171
</header>
172172
<article class="editor multiline"><div class="pad">
173173
<textarea>
174-
RegExr v3 was created by gskinner.com, and is proudly hosted by Media Temple.
174+
RegExr was created by gskinner.com, and is proudly hosted by Media Temple.
175175

176176
Edit the Expression & Text to see matches. Roll over matches or the expression for details. PCRE & Javascript flavors of RegEx are supported.
177177

0 commit comments

Comments
 (0)