-
Notifications
You must be signed in to change notification settings - Fork 7
/
gruntfile.js
124 lines (113 loc) · 4.01 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
116
117
118
119
120
121
122
123
124
module.exports = function (grunt) {
function execCmd(cmd, args, done) {
grunt.util.spawn({
cmd: cmd,
args: args
}, function (error, result) {
if (error) {
grunt.log.error(error);
} else {
grunt.log.write(result);
}
done();
});
}
var workingDir = "dist/_build";
var bannerSrc = workingDir + "/banner.js";
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
concat: {
build: {
src: [
bannerSrc,
"build/header.js",
"src/namespace.js",
"src/utils.js",
"src/subscriptions.js",
"src/binder.js",
"src/bindings/*.js",
"build/footer.js"
],
dest: "dist/<%= pkg.name %>-<%= pkg.version %>.debug.js"
}
},
uglify: {
options: {
banner: grunt.file.read("build/banner.tmpl")
},
build: {
src: ["<%= concat.build.dest %>"],
dest: "dist/<%= pkg.name %>-<%= pkg.version %>.js"
}
},
jshint: {
build: {
options: {
'-W004': true
},
src: [
"<%= concat.build.dest %>"
]
}
},
jasmine: {
options: {
//keepRunner: true,
vendor: [
"node_modules/knockout/build/output/knockout-latest.js",
"http://maps.googleapis.com/maps/api/js?sensor=false&extension=.js"
],
helpers: [
"test/jasmine.extensions.js"
],
specs: ["test/Spec/**/*Spec.js"]
},
build: {
src: ["<%= concat.build.dest %>"]
}
}
});
grunt.loadNpmTasks("grunt-contrib-concat");
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-contrib-jasmine");
grunt.registerTask("prepare", "Prepare the build", function () {
grunt.file.mkdir(workingDir);
});
grunt.registerTask("generateBanner", "Generate the banner", function () {
var bannerTmpl = grunt.file.read("build/banner.tmpl");
var banner = grunt.template.process(bannerTmpl);
grunt.file.write(bannerSrc, banner);
});
grunt.registerTask("nugetPack", "Create a NuGet package", function () {
execCmd("nuget.exe", [
//specify the .nuspec file
"pack", "build/knockout.google.maps.nuspec",
//specify where we want the package to be created
"-OutputDirectory", "dist",
// specify base path as project root directory
"-BasePath", ".",
//override the version with whatever is currently defined in package.json
"-Version", grunt.config.get("pkg").version
], this.async());
});
grunt.registerTask("nugetPush", "Publish a NuGet package", function () {
var args = ["push", "dist\\*.nupkg"];
var apiKey = grunt.option("apiKey");
if (apiKey) {
args = args.concat(["-ApiKey", apiKey]);
}
execCmd("nuget.exe", args, this.async());
});
grunt.registerTask("clean", "Cleaning build directory", function () {
grunt.file.delete(workingDir);
});
grunt.registerTask("assemble", ["prepare", "generateBanner", "concat", "uglify", "clean"]);
grunt.registerTask("runTest", ["jshint", "jasmine"]);
grunt.registerTask("test", ["assemble", "runTest"]);
grunt.registerTask("build", ["test", "nugetPack"]);
grunt.registerTask("publish", ["nugetPush"]);
grunt.registerTask("buildAndPublish", ["build", "publish"]);
grunt.registerTask("default", ["build"]);
};