-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgulpfile.js
73 lines (62 loc) · 1.91 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
var gulp = require('gulp');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var rename = require('gulp-rename');
var streamify = require('gulp-streamify');
var uglify = require('gulp-uglify');
var del = require('del');
var crx = require('gulp-crx-pack');
var fs = require('fs');
var zip = require('gulp-vinyl-zip');
var execSync = require('child_process').execSync;
gulp.task('test', function(done) {
browserify("src/kanban/app.js")
.bundle()
.pipe(source("app.js"))
.pipe(rename('bundle.js'))
.pipe(gulp.dest("src/kanban/"));
var result = execSync('node_modules/phantomjs-prebuilt/bin/phantomjs test/run.js').toString();
if (result.search('failing') === -1) {
done();
} else {
done(new Error('test failed'));
}
});
gulp.task('clean:work', ['test'], function() {
return del(['work/**/*']);
});
gulp.task('copy:work', ['clean:work'], function() {
return gulp.src('src/**')
.pipe(gulp.dest('work'));
});
gulp.task('uglify', ['copy:work'], function() {
return gulp.src('work/*.js')
.pipe(streamify(uglify()))
.pipe(gulp.dest('work'));
});
gulp.task('browserify', ['uglify'], function() {
browserify("work/kanban/app.js")
.bundle()
.pipe(source("app.js"))
.pipe(streamify(uglify()))
.pipe(rename('bundle.js'))
.pipe(gulp.dest("work/kanban/"));
});
gulp.task('crx', ['browserify'],function() {
return gulp.src('work')
.pipe(crx({
privateKey: fs.readFileSync('keys/chrome.pem', 'utf8'),
filename: 'chrome.crx'
}))
.pipe(gulp.dest('./dist'));
});
gulp.task('copy:chrome-key', ['crx'], function() {
execSync('cp keys/chrome.pem work/key.pem');
});
gulp.task('packaging:chrome', ['copy:chrome-key'], function() {
return gulp.src('work/**/*')
.pipe(zip.dest('dist/chrome.zip'));
});
gulp.task('build', ['packaging:chrome'], function() {
});
gulp.task('default', ['build']);