fix failing to build without .git directory

This commit is contained in:
MaysWind 2019-03-19 00:44:38 +08:00
parent 61e24f19e2
commit 8b0974cd6f
3 changed files with 10 additions and 2 deletions

View file

@ -4,6 +4,7 @@ var browserSync = require('browser-sync');
var del = require('del');
var fs = require('fs');
var git = require('git-rev-sync');
var tryFn = require('nice-try');
var $ = gulpLoadPlugins();
var reload = browserSync.reload;
@ -56,7 +57,7 @@ gulp.task('prepare-scripts', function () {
'src/scripts/**/*.js'
]).pipe($.plumber())
.pipe($.injectVersion({replace: '${ARIANG_VERSION}'}))
.pipe($.replace(/\${ARIANG_BUILD_COMMIT}/g, git.short()))
.pipe($.replace(/\${ARIANG_BUILD_COMMIT}/g, tryFn(git.short) || 'Local'))
.pipe(gulp.dest('.tmp/scripts'))
.pipe(reload({stream: true}));
});

6
package-lock.json generated
View file

@ -7652,6 +7652,12 @@
"integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=",
"dev": true
},
"nice-try": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/nice-try/-/nice-try-2.0.0.tgz",
"integrity": "sha512-/o4KoXbUkEjD2NDwvBCkSzEDOfMuHPmbzSD5Pp2Bb5U/69MnEvpc4YfW2Y1BJqJpcaam04+fR0kF8n5xm8b6MQ==",
"dev": true
},
"no-case": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/no-case/-/no-case-2.3.2.tgz",

View file

@ -61,7 +61,8 @@
"gulp-size": "^3.0.0",
"gulp-sourcemaps": "^2.6.5",
"gulp-uglify": "^2.1.2",
"gulp-useref": "^3.1.6"
"gulp-useref": "^3.1.6",
"nice-try": "^2.0.0"
},
"name": "ariang",
"description": "AriaNg, a modern web frontend making aria2 easier to use.",