forked from jshint/jshint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.js
executable file
·116 lines (92 loc) · 2.1 KB
/
make.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
"use strict";
require("shelljs/make");
var cli = require("cli");
var TESTS = [
"tests/stable/unit/",
"tests/stable/regression/",
"tests/next/unit/"
];
var OPTIONS = {
es5: true,
boss: true,
node: true,
globalstrict: true,
strict: true,
white: true,
smarttabs: true,
maxlen: 100,
newcap: false,
undef: true,
unused: true,
onecase: true
};
target.all = function () {
target.lint();
target.test();
target.build();
};
target.lint = function () {
var jshint = require("jshint").JSHINT;
var files = find("src").filter(function (file) {
return file.match(/\.js$/);
});
TESTS.forEach(function (dir) {
ls(dir + "*.js").forEach(function (file) {
files.push(file);
});
});
echo("Linting files...", "\n");
var failures = {};
files.forEach(function (file) {
var passed = jshint(cat(file), OPTIONS);
process.stdout.write(passed ? "." : "F");
if (!passed) {
failures[file] = jshint.data();
}
});
echo("\n");
if (Object.keys(failures).length == 0) {
cli.ok("All files passed.");
return;
}
for (var key in failures) {
cli.error(key);
failures[key].errors.forEach(function (err) {
if (!err) {
return;
}
var line = "[L" + err.line + "]";
while (line.length < 10) {
line += " ";
}
echo(line, err.reason);
});
echo("\n");
}
exit(1);
};
target.test = function () {
var nodeunit = require("nodeunit").reporters.minimal;
var files = [];
TESTS.forEach(function (dir) {
ls(dir + "*.js").forEach(function (file) {
files.push(file);
});
});
echo("Running tests...", "\n");
nodeunit.run(files);
};
target.build = function () {
echo("Building platform wrappers:");
var rhino = cat("./src/stable/jshint.js", "./src/platforms/rhino.js");
rhino = "#!/usr/bin/env rhino\n\n" + rhino;
rhino.to("./dist/jshint-rhino.js");
exec("chmod +x dist/jshint-rhino.js");
cli.ok("Rhino");
cat("./src/platforms/wsh.js").to("./dist/jshint-wsh.js");
cli.ok("Windows Script Host");
cat("./src/platforms/jsc.sh").to("./dist/jshint-jsc.sh");
cat("./src/platforms/jsc.js").to("./dist/jshint-jsc.js");
exec("chmod +x dist/jshint-jsc.sh");
cli.ok("JavaScript Core");
};