forked from NordMagnus/Trello-Folds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
54 lines (51 loc) · 1.88 KB
/
Gruntfile.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
module.exports = function(grunt) {
grunt.loadNpmTasks("grunt-mocha-test");
grunt.loadNpmTasks("grunt-contrib-compress");
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
manifest: grunt.file.readJSON("extension/manifest.json"),
mochaTest: {
test: {
options: {
reporter: "list",
},
src: ["test/**/*.tests.js"],
},
},
compress: {
main: {
options: {
archive: "dist/Trello-Folds-<%= pkg.version %>.zip",
},
files: [
{expand: true, cwd: "extension/", src: ["**"], dest: "/"},
],
},
},
});
//grunt.registerTask("test", "mochaTest");
grunt.registerTask("default", "test");
grunt.registerTask("test", "Runs Mocha tests", function() {
grunt.task.run("mochaTest");
});
grunt.registerTask("zip", "compress");
grunt.registerTask("version-check", "Checks that package.json and manifest.json version matches", function() {
let packageVer = grunt.config("pkg").version;
let manifestVer = grunt.config("manifest").version;
if (packageVer !== manifestVer) {
grunt.log.error(`package.json [${packageVer}] and manifest.json [${manifestVer}] versions do not match`);
return false;
}
grunt.log.writeln(`Versions match: ${packageVer}`);
});
grunt.registerTask("build", function() {
grunt.task.run("version-check");
let packageVersion = grunt.config("pkg").version;
if (grunt.file.exists(`dist/Trello-Folds-${packageVersion}.zip`)) {
grunt.fail.warn("File already exists");
}
grunt.option("reporter", "progress");
grunt.task.run("test");
grunt.task.run("zip");
});
};