forked from globalizejs/react-globalize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
58 lines (54 loc) · 1.72 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
module.exports = function(grunt) {
grunt.loadNpmTasks("grunt-esperanto");
grunt.loadNpmTasks("grunt-mocha-test");
grunt.loadNpmTasks("grunt-eslint");
grunt.initConfig({
esperanto: {
amd: {
options: {
type: "amd"
},
expand: true,
cwd: "src",
src : ["**.js", "!index.js"],
dest: "dist/amd/"
},
cjs: {
options: {
type: "cjs"
},
expand: true,
cwd: "src",
src : ["**.js"],
dest: "dist/"
}
},
mochaTest: {
test: {
options: {
colors: true,
require: ["babel-register", "./test/test_setup.js"]
},
src: ["test/**/*.js"]
}
},
eslint: {
target: ["Gruntfile.js", "test", "src"]
}
});
grunt.registerTask("esperanto-cjs-cleanup", function() {
grunt.file.expand("dist/**.js").map(function(filepath) {
var newContent;
var content = grunt.file.read(filepath);
// Remove entries like /^require("globalize/currency");$/
newContent = content.replace(/require\('globalize\/.*/g, "");
if (content !== newContent) {
grunt.file.write(filepath, newContent);
}
});
});
grunt.registerTask("build", ["esperanto", "esperanto-cjs-cleanup"]);
grunt.registerTask("lint", ["eslint"]);
grunt.registerTask("test", ["lint", "build", "mochaTest"]);
grunt.registerTask("default", ["build"]);
};