forked from gnab/editableCell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.js
74 lines (59 loc) · 1.72 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
require('shelljs/make');
require('shelljs/global');
// Targets
target.all = function () {
target.lint();
target.bundle();
target.test();
target.minify();
};
target.lint = function () {
console.log('Linting...');
run('jshint src', {silent: true});
};
target.bundle = function () {
console.log('Bundling...');
run('browserify --external knockout -s editableCell src/editableCell.js', {silent: true})
.output
// Add 'knockout' as a dependency for AMD scenario
.replace('define(e);', 'define([\'knockout\'],e);')
.to('out/editableCell.js');
};
target.minify = function () {
console.log('Minifying...');
run('uglifyjs out/editableCell.js', {silent: true}).output.to('out/editableCell.min.js');
};
target['test-bundle'] = function () {
console.log('Bundling tests...');
[
"require('should');"
]
.concat(find('./test')
.filter(function(file) { return file.match(/\.js$/); })
.map(function (file) { return "require('./" + file + "');" })
)
.join('\n')
.to('_tests.js');
run('browserify _tests.js', {silent: true}).output.to('out/tests.js');
rm('_tests.js');
};
target.test = function () {
target['test-bundle']();
console.log('Running tests...');
run('mocha-phantomjs test/runner.html');
};
// Helper functions
var path = require('path');
function less (file) {
return run('lessc -x ' + file, {silent: true}).output.replace(/\n/g, '');
}
function run (command, options) {
var result = exec(path.join('node_modules/.bin/') + command, options);
if (result.code !== 0) {
if (!options || options.silent) {
console.error(result.output);
}
exit(1);
}
return result;
}