-
Notifications
You must be signed in to change notification settings - Fork 12
/
Gruntfile.js
95 lines (81 loc) · 2.93 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
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
* Copyright The UIO+ for Morphic copyright holders
* See the AUTHORS.md file at the top-level directory of this distribution and at
* https://github.com/GPII/gpii-chrome-extension/blob/master/AUTHORS.md
*
* Licensed under the New BSD license. You may not use this file except in
* compliance with this license.
*
* You may obtain a copy of the license at
* https://github.com/GPII/gpii-chrome-extension/blob/master/LICENSE.txt
*/
/* global module */
"use strict";
var merge = require("deepmerge");
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
buildVersion: "<%= pkg.version %>",
lintAll: {
sources: {
md: [ "./*.md"],
js: ["./tests/**/*.js", "./src/**/*.js", "./*.js"],
json: ["./src/**/*.json", "./*.json", "./.*.json"],
other: ["./.*"]
}
},
clean: {
all: {
src: ["dist/"]
}
},
writeManifest: {
options: {
space: 4
},
all: {
src: ["dist/manifest.json", "src/manifest.json"],
dest: "dist/manifest.json"
}
},
copy: {
"uio+": {
cwd: "node_modules/uio-plus/dist",
expand: true,
dest: "dist/",
src: ["**/*"]
},
source: {
cwd: "src",
expand: true,
src: [
"js/**/*"
],
dest: "dist/"
}
}
});
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("gpii-grunt-lint-all");
grunt.registerTask("lint", "Perform all standard lint checks.", ["lint-all"]);
// Can specify a replacer or space option to be used by the JSON.stringify call
// see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
grunt.registerMultiTask("writeManifest", "Outputs a manifest file by merging the source documents into the destination.", function () {
var options = this.options();
var version_name = grunt.option("version_name");
var overwriteMerge = function (destinationArray, sourceArray) {
return sourceArray;
};
var inputs = this.filesSrc.map(function (fileSrc) {
return grunt.file.readJSON(fileSrc);
});
var output = merge.all(inputs, { arrayMerge: overwriteMerge });
if (version_name) {
output = merge(output, {version_name: version_name});
}
grunt.file.write(this.data.dest, JSON.stringify(output, options.replacer, options.space));
});
grunt.registerTask("build", "Build the extensions", ["clean", "copy", "writeManifest"]);
grunt.registerTask("default", ["build"]);
};