-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
93 lines (72 loc) · 2.24 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
var gulp = require('gulp');
var nodemon = require('gulp-nodemon');
require('gulp-plumber');
var livereload = require('gulp-livereload');
var sass = require('gulp-ruby-sass');
var path = require('path');
var zip = require('gulp-zip');
var minimist = require('minimist');
var fs = require('fs');
var moment = require('moment');
gulp.task('sass', function () {
return sass('./public/css/**/*.scss')
.pipe(gulp.dest('./public/css'))
.pipe(livereload());
});
gulp.task('watch', function () {
gulp.watch('./public/css/*.scss', ['sass']);
});
gulp.task('develop', function () {
livereload.listen();
nodemon({
script: 'bin/www',
ext: 'js coffee jade',
stdout: false
}).on('readable', function () {
this.stdout.on('data', function (chunk) {
if (/^Express server listening on port/.test(chunk)) {
livereload.changed(__dirname);
}
});
this.stdout.pipe(process.stdout);
this.stderr.pipe(process.stderr);
});
});
var knownOptions = {
string: ['packageName', 'packagePath', 'packageBuildId', 'packageVersionFilepath'],
default: {
packageName: 'Package.zip',
packagePath: path.join(__dirname, '_package'),
packageBuildId: 'None',
packageVersionFilepath: 'version.txt'
}
};
var options = minimist(process.argv.slice(2), knownOptions);
gulp.task('package', function () {
var versionContent = 'Package Time: ' + moment().format() + '\n' +
'Build ID: ' + options.packageBuildId;
fs.writeFileSync(options.packageVersionFilepath, versionContent);
var packagePaths = ['**',
'!**/_package/**',
'!**/typings/**',
'!typings',
'!_package',
'!gulpfile.js'];
// add exclusion patterns for all dev dependencies
var packageJSON = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8'));
var devDeps = packageJSON.devDependencies;
for (var propName in devDeps) {
var excludePattern1 = '!**/node_modules/' + propName + '/**';
var excludePattern2 = '!**/node_modules/' + propName;
packagePaths.push(excludePattern1);
packagePaths.push(excludePattern2);
}
return gulp.src(packagePaths)
.pipe(zip(options.packageName))
.pipe(gulp.dest(options.packagePath));
});
gulp.task('default', gulp.series(
'sass',
'develop',
'watch'
));