Skip to content

Commit 406d6cf

Browse files
Merge pull request #2 from NativeScript/milanov/setup-grunt
Setup Grunt
2 parents 663fe7e + 312182c commit 406d6cf

File tree

4 files changed

+117
-3
lines changed

4 files changed

+117
-3
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,6 @@ test-reports.xml
6363

6464
*.js
6565
*.js.map
66-
/lib/.d.ts
66+
/lib/.d.ts
67+
68+
!/*.js

Gruntfile.js

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
module.exports = function (grunt) {
2+
grunt.initConfig({
3+
ts: {
4+
options: grunt.file.readJSON("tsconfig.json").compilerOptions,
5+
6+
devlib: {
7+
src: ["lib/**/*.ts"],
8+
reference: "lib/.d.ts"
9+
},
10+
11+
devall: {
12+
src: ["lib/**/*.ts", "test/**/*.ts"],
13+
reference: "lib/.d.ts"
14+
},
15+
16+
release_build: {
17+
src: ["lib/**/*.ts", "test/**/*.ts"],
18+
reference: "lib/.d.ts",
19+
options: {
20+
sourceMap: false,
21+
removeComments: true
22+
}
23+
}
24+
},
25+
26+
tslint: {
27+
build: {
28+
files: {
29+
src: ["lib/**/*.ts", "test/**/*.ts", "!**/*.d.ts"]
30+
},
31+
options: {
32+
configuration: grunt.file.readJSON("./tslint.json")
33+
}
34+
}
35+
},
36+
37+
watch: {
38+
devall: {
39+
files: ["lib/**/*.ts", 'test/**/*.ts'],
40+
tasks: [
41+
'ts:devall',
42+
'shell:npm_test'
43+
],
44+
options: {
45+
atBegin: true,
46+
interrupt: true
47+
}
48+
},
49+
ts: {
50+
files: ["lib/**/*.ts", "test/**/*.ts"],
51+
tasks: [
52+
'ts:devall'
53+
],
54+
options: {
55+
atBegin: true,
56+
interrupt: true
57+
}
58+
}
59+
},
60+
61+
shell: {
62+
options: {
63+
stdout: true,
64+
stderr: true,
65+
failOnError: true
66+
},
67+
build_package: {
68+
command: "npm pack"
69+
},
70+
npm_test: {
71+
command: "npm test"
72+
}
73+
},
74+
75+
clean: {
76+
src: ["test/**/*.js*", "lib/**/*.js*", "!lib/hooks/**/*.js", "!Gruntfile.js", "*.tgz"]
77+
}
78+
});
79+
80+
grunt.loadNpmTasks("grunt-contrib-clean");
81+
grunt.loadNpmTasks("grunt-contrib-watch");
82+
grunt.loadNpmTasks("grunt-shell");
83+
grunt.loadNpmTasks("grunt-ts");
84+
grunt.loadNpmTasks("grunt-tslint");
85+
86+
grunt.registerTask("delete_coverage_dir", function () {
87+
var done = this.async();
88+
var rimraf = require("rimraf");
89+
rimraf("coverage", function (err) {
90+
if (err) {
91+
console.log("Error while deleting coverage directory from the package: ", err);
92+
done(false);
93+
}
94+
95+
done();
96+
});
97+
});
98+
99+
grunt.registerTask("test", ["ts:devall", "shell:npm_test"]);
100+
101+
grunt.registerTask("pack", [
102+
"clean",
103+
"ts:release_build",
104+
"shell:npm_test",
105+
"delete_coverage_dir",
106+
"shell:build_package"
107+
]);
108+
grunt.registerTask("lint", ["tslint:build"]);
109+
grunt.registerTask("all", ["clean", "test", "lint"]);
110+
grunt.registerTask("rebuild", ["clean", "ts:devlib"]);
111+
grunt.registerTask("default", "ts:devlib");
112+
};

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@
2424
"devDependencies": {
2525
"grunt": "1.0.1",
2626
"grunt-contrib-clean": "1.0.0",
27+
"grunt-contrib-watch": "1.0.0",
2728
"grunt-shell": "2.0.0",
2829
"grunt-ts": "6.0.0-beta.3",
2930
"grunt-tslint": "3.3.0",
3031
"istanbul": "0.4.5",
3132
"mocha": "3.1.2",
33+
"rimraf": "2.5.4",
3234
"tslint": "3.15.1",
3335
"typescript": "2.0.3"
3436
}

tsconfig.json

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
},
1111
"exclude": [
1212
"node_modules",
13-
"lib/common/node_modules",
14-
"scratch",
1513
"coverage"
1614
]
1715
}

0 commit comments

Comments
 (0)