forked from softvar/enhanced-github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
80 lines (67 loc) · 2.19 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
var gulp = require('gulp');
var clean = require('gulp-clean');
var jshint = require('gulp-jshint');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var zip = require('gulp-zip');
var watch = require('gulp-watch');
var APP_NAME = 'enhanced-github';
var bases = {
app: 'src/',
dist: 'enhanced-github-zip/',
};
var paths = {
vendor: [ 'node_modules/clipboard/dist/clipboard.min.js' ],
scripts: [ 'src/*.js', 'options.js', 'popup.js' ],
html: [ '*.html' ],
manifest: [ 'manifest.json' ],
icons: [ 'icons/*.png' ],
zip: [ `${APP_NAME}.zip` ]
};
gulp.task('clean-zip', function() {
return gulp.src(paths.zip)
.pipe(clean());
});
// Delete the dist directory
gulp.task('clean', ['clean-zip'], function() {
return gulp.src(bases.dist)
.pipe(clean());
});
// Process scripts and concatenate them into one output file
gulp.task('scripts', ['clean'], function() {
gulp.src(paths.scripts, {cwd: bases.app})
.pipe(jshint())
.pipe(jshint.reporter('default'))
});
// Copy all other files to dist directly
gulp.task('copy-clipboard-file', ['clean'], function() {
// Copy html
gulp.src(paths.vendor)
.pipe(gulp.dest(bases.app));
});
// Copy all other files to dist directly
gulp.task('copy', ['clean'], function() {
// Copy html
gulp.src(paths.html, {base: '.'})
.pipe(gulp.dest(bases.dist));
// Copy lib scripts, maintaining the original directory structure
gulp.src(paths.scripts, {base: '.'})
.pipe(gulp.dest(bases.dist));
// Copy icons, maintaining the original directory structure
gulp.src(paths.icons, {base: '.'})
.pipe(gulp.dest(bases.dist));
// Copy manifest.json, maintaining the original directory structure
gulp.src(paths.manifest, {base: '.'})
.pipe(gulp.dest(bases.dist));
});
// Delete the dist directory
gulp.task('zip', ['clean-zip'], function() {
return gulp.src('enhanced-github-zip/**/*')
.pipe(zip(APP_NAME + '.zip'))
.pipe(gulp.dest('.'));
});
gulp.task('watch' , function () {
return gulp.watch([paths.scripts, paths.html, paths.icons, paths.manifest], ['default']);
});
// Define the default task as a sequence of the above tasks
gulp.task('default', ['copy-clipboard-file', 'clean', 'scripts', 'copy']);