-
Notifications
You must be signed in to change notification settings - Fork 8
/
Gruntfile.js
115 lines (104 loc) · 3.97 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
"use strict";
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
clean: {
tests: ["build/test/"]
},
copy: {
tests: {
files: [
{ expand: true, cwd: "test", src: ["**"], dest: "build/test" },
{ expand: true, cwd: "node_modules/mocha/", src: ["mocha.js", "mocha.css"], dest: "build/test/inte" }
]
}
},
browserify: {
integration: {
files: {
"dist/integration.js": ["lib/integration.js"]
},
options: {
browserifyOptions: {
standalone: "obsidianApp"
}
}
},
application: {
files: {
"dist/obsidian-api.js": ["lib/index.js"]
},
options: {
browserifyOptions: {
standalone: "ObsidianApi"
}
}
},
testInte: {
files: {
"build/test/inte/tests.generated.js": ["test/*.js"]
},
options: {
browserifyOptions: {
debug: true
}
}
},
testApp: {
files: {
"build/test/app/app.generated.js": ["test/app/app.js"]
},
options: {
browserifyOptions: {
debug: true
}
}
}
},
uglify: {
dist: {
files: {
"dist/integration.min.js": "dist/integration.js",
"dist/obsidian-api.min.js": "dist/obsidian-api.js"
}
}
},
jshint: {
all: ["lib/*.js"],
options: {
jshintrc: true
}
},
shell: {
serverStart: {
command: [
"node node_modules/.bin/pm2 delete wanadev-project-api-app > /dev/null 2> /dev/null || echo -n",
"node node_modules/.bin/pm2 delete wanadev-project-api-inte > /dev/null 2> /dev/null || echo -n",
"node node_modules/.bin/pm2 start -f build/test/app/server.js --name=obsidian-api-app --watch > /dev/null 2> /dev/null",
"node node_modules/.bin/pm2 start -f build/test/inte/server.js --name=obsidian-api-inte --watch",
"sleep 1"
].join(" && ")
},
serverStop: {
command: [
"node node_modules/.bin/pm2 delete obsidian-api-app > /dev/null 2> /dev/null",
"node node_modules/.bin/pm2 delete obsidian-api-inte"
].join(" && ")
},
mocha_headless_chrome: {
command: "npx mocha-headless-chrome -f http://localhost:3010 --args no-sandbox",
},
}
});
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("grunt-browserify");
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-shell");
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.registerTask("default", ["gen-inte", "gen-app", "uglify"]);
grunt.registerTask("gen-inte", "Generates the dist integration script", ["browserify:integration"]);
grunt.registerTask("gen-app", "Generates the dist application script", ["browserify:application"]);
grunt.registerTask("gen-test", "Generates the test scripts", ["clean:tests", "copy:tests", "browserify:testInte", "browserify:testApp"]);
grunt.registerTask("test", "Run tests in a web browser", ["jshint", "gen-test", "shell:serverStart", "shell:mocha_headless_chrome", "shell:serverStop"]);
};