forked from softvar/enhanced-github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
66 lines (55 loc) · 1.78 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
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 = 'github-plus';
var bases = {
app: 'src/',
dist: 'github-plus-zip/',
};
var paths = {
scripts: [ 'src/*.js', 'options.js', 'popup.js' ],
html: [ '*.html' ],
manifest: [ 'manifest.json' ],
icons: [ 'icons/*.png' ],
};
// Delete the dist directory
gulp.task('clean', 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', ['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', function() {
return gulp.src('github-plus-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', ['clean', 'scripts', 'copy']);