-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathGruntfile.js
126 lines (113 loc) · 3.05 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
125
126
module.exports = function(grunt) {
grunt.initConfig({
jshint: {
files: ['grunt.js', 'tasks/**/*.js']
},
'node-qunit': {
// Just a simple test
case1: {
code: "./test/code/code.js",
tests: "./test/testFiles/tests.js"
},
// Using Code with array
case2: {
code: "./test/code/code.js",
tests: ["./test/testFiles/codetest.js", "./test/testFiles/tests.js"]
},
// Requires dependency
case3: {
code: "./test/code/code.js",
deps: "./test/dependency/dependency.js",
tests: ["./test/testFiles/codetest.js", "./test/testFiles/deptest.js"]
},
// Wildcard in test path
// TODO Fix wildcards in file paths
case4: {
code: "./test/code/code.js",
deps: "./test/dependency/dependency.js",
tests: ["./test/testFiles/tests.js"]
},
// require code into a namespace object, rather than globally
case5: {
code: {
path: "./test/code/code.js",
namespace: "code"
},
tests: "./test/testFiles/tests.js"
},
// using callback
case6: {
code: "./test/code/code.js",
tests: "./test/testFiles/tests.js",
callback: function() {
grunt.log.write("Case5 Callback invoked");
}
},
// Ignoring a failing test
case7: {
deps: "./test/dependency/dependency.js",
code: "./test/code/code.js",
tests: ["./test/testFiles/tests.js", "./test/testFiles/tests.js", "./test/testFiles/failtest.js"],
callback: function(status) {
grunt.log.write("Status of this test was " + status);
return true;
}
},
// Aync in callback
case8: {
deps: "./test/dependency/dependency.js",
code: "./test/code/code.js",
tests: ["./test/testFiles/tests.js"],
callback: function() {
var done = this.async();
setTimeout(function() {
done();
}, 100);
}
},
// Async in callback, ignoring test result
case9: {
deps: "./test/dependency/dependency.js",
code: "./test/code/code.js",
tests: ["./test/testFiles/tests.js", "./test/testFiles/failtest.js"],
callback: function(status) {
grunt.log.write("Status of the tests is " + status);
var done = this.async();
setTimeout(function() {
done(true);
}, 100);
}
}
},
publish: {
npm: {
username: process.env.NPM_USERNAME,
password: process.env.NPM_PASSWORD,
email: process.env.NPM_EMAIL
}
}
});
grunt.registerMultiTask('publish', 'Publish the latest version of this plugin', function() {
var done = this.async(),
me = this,
npm = require('npm');
npm.load({}, function(err) {
npm.registry.adduser(me.data.username, me.data.password, me.data.email, function(err) {
if (err) {
console.log(err);
done(false);
} else {
npm.config.set("email", me.data.email, "user");
npm.commands.publish([], function(err) {
console.log(err || "Published to registry");
done(!err);
});
}
});
});
});
grunt.loadTasks('tasks');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.registerTask('default', ['jshint', 'test']);
grunt.registerTask('test', ['node-qunit', 'publish']);
};