-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
69 lines (61 loc) · 2.06 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
/*global __dirname*/
const fs = require("fs");
const gulp = require("gulp");
const crx = require("gulp-crx-pack");
const manifest = require("./src/manifest.json");
const Server = require("karma").Server;
const zip = require("gulp-zip");
const shell = require("gulp-shell");
const eslint = require("gulp-eslint");
const del = require("del");
const src = __dirname + "\\src";
const jsonEditor = require("gulp-json-editor");
const selectorGeneratorSrc = "./node_modules/selector-generator/selector-generator.js";
gulp.task("clean", function(){
return del(["./src/js/selector-generator.js"]);
});
gulp.task("copy",["clean"], function(){
return gulp.src(selectorGeneratorSrc)
.pipe(gulp.dest("./src/js"));
});
gulp.task("crx",["build"], function () {
return gulp.src("./src")
.pipe(crx({
privateKey: fs.readFileSync("./certs/key.pem", "utf8"),
filename: manifest.name + ".crx"
}))
.pipe(gulp.dest("./build"));
});
gulp.task("zip",["build"], function () {
return gulp.src("./src/**")
.pipe(zip(manifest.name + ".zip"))
.pipe(gulp.dest("./build"));
});
gulp.task("test", ["copy"],function (done) {
new Server({
configFile: __dirname + "/karma.conf.js",
singleRun: true
}, done).start();
});
gulp.task("build",["copy","increment"]);
gulp.task("pack",["zip", "crx"]);
gulp.task("increment", function () {
var numbers = manifest.version.split(".");
numbers[3]++;
var version = numbers.join(".");
return gulp.src(["./src/manifest.json"])
.pipe(jsonEditor({
"version": version
}))
.pipe(gulp.dest(function (file) {
return file.base;
}));
});
gulp.task("chrome", shell.task(["\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\" --load-extension=" + src]));
gulp.task("eslint", ["copy"], function () {
return gulp.src(["./src/js/**/*.js", "./tests/*.spec.js"])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task("default", ["test","eslint","build","pack"]);