-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jakefile.js
117 lines (90 loc) · 3.02 KB
/
Jakefile.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
/*global desc, task, jake, fail, complete */
(function() {
"use strict";
var NODE_VERSION = "v0.11.14-pre";
task('default', ["lint","test","nodeVersion", "ghost"]);
//Casper smoke tests
desc("Casper smoke test");
task("ghost", [], function(){
var ghost = require("./src/smoke_test.js");
console.log("Casper starts phantom!");
ghost.ghostFunc();
}, {async: true});
// Ensure correct version of node is present
desc("Ensure correct version of node is present");
task("nodeVersion", [], function(){
function failWithQualifier(qualifier){
fail("Incorrect node version. Expected " + qualifier + "[ " + expectedString + " ], but was [" + actualString + " ].");
}
var expectedString = NODE_VERSION;
var actualString = process.version;
var expected = parseNodeVersion( "expected Node version", expectedString);
var actual = parseNodeVersion( "actual Node version", actualString);
if(process.env.strict) {
if (actual[0] !== expected[0] || actual[1] !== expected[1] || actual[2] !== expected[2]) {
failWithQualifier("exactly");
}else{
if (actual[0] < expected [0]) failWithQualifier("at least");
if(actual[0] === expected[0] && actual[1] < expected[1]) failWithQualifier("at least");
if(actual[0]=== expected[0] && actual[1] === expected[1] && actual[2] < expected[2]) failWithQualifier("at least"); }
}
console.log(" Node version was ", parseNodeVersion(" ", NODE_VERSION));
});
function parseNodeVersion(description, versionString){
var versionMatcher = /^v(\d+)\.(\d+)\.(\d+).+[a-zA-Z]$/;
var versionInfo = versionString.match(versionMatcher);
if(versionInfo === null) fail ("Could not parse " + description + " (was'" + versionString + "')");
var major = parseInt(versionInfo[1], 10);
var minor = parseInt(versionInfo[2], 10);
var bugfix = parseInt(versionInfo[3], 10);
return [major, minor, bugfix];
}
//JSHint
desc("Lints eveything");
task("lint", ["nodeVersion"], function(){
var lint = require("./build/lint/lint_runner.js");
var files = new jake.FileList();
files.include("**/*.js");
files.exclude("node_modules");
var options = nodeLintOptions();
var globals = nodeLintGlobals();
var pass = lint.validateFileList(files.toArray(), options, globals);
if (!pass) fail("Lint failed");
});
//nodeunit
desc("Test everything");
task("test", ["nodeVersion"], function(){
var reporter = require("nodeunit").reporters["default"];
reporter.run(['src/server/_server_test.js'], null, function(failures){
console.log("All tests done"); // add with server running
complete(); // deploy node ./server.sh
});
}, {async: true});
function nodeLintOptions(){
return {
bitwise: true,
curly: false,
eqeqeq: true,
forin: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
noempty: true,
nonew: true,
regexp: true,
undef: true,
strict: true,
trailing: true,
node: true
};
}
function nodeLintGlobals(){
return {
describe: false,
it: false,
beforeEach: false,
afterEach: false
};
}
}());