Skip to content

Commit 05fb3d2

Browse files
committed
sorted out dependencies
1 parent 6d6f1b2 commit 05fb3d2

File tree

2 files changed

+53
-16
lines changed

2 files changed

+53
-16
lines changed

build/bin/init.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source build/bin/config.sh
2+
3+
rm -rf $OUTPUT
4+
rm -rf tmp

grunt.js

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
var util = require('util'),
2+
child_process = require('child_process');
3+
14
/*global module:false*/
25
module.exports = function(grunt) {
36

@@ -13,7 +16,8 @@ module.exports = function(grunt) {
1316
options: {
1417
curly: true,
1518
eqeqeq: true,
16-
immed: false, /* (function(){})() seems acceptable */
19+
// (function(){})() seems acceptable
20+
immed: false,
1721
latedef: true,
1822
newcap: true,
1923
noarg: true,
@@ -26,7 +30,8 @@ module.exports = function(grunt) {
2630
globals: {
2731
jQuery: true,
2832

29-
/* qunit globals */
33+
// qunit globals
34+
// TODO would be nice to confine these to test files
3035
module: true,
3136
ok: true,
3237
test: true,
@@ -36,15 +41,28 @@ module.exports = function(grunt) {
3641
stop: true,
3742
expect: true,
3843

39-
/* require js global */
44+
// require js global
4045
define: true
4146
}
4247
},
43-
legacy: {
44-
css: true,
45-
js: true,
46-
docs: true,
47-
zip: true
48+
legacy_tasks: {
49+
init: {},
50+
css: {
51+
deps: [ 'init' ]
52+
},
53+
js: {
54+
deps: [ 'init' ]
55+
},
56+
docs: {
57+
deps: [ 'init', 'js', 'css' ]
58+
},
59+
zip: {
60+
deps: [ 'init', 'js', 'css' ]
61+
},
62+
deploy: {
63+
deps: [ 'clean', 'init', 'js', 'css', 'docs', 'zip' ],
64+
env: "IS_DEPLOY_TARGET=true"
65+
}
4866
},
4967
lint: {
5068
files: ['grunt.js', 'js/*.js', 'tests/**/*.js']
@@ -73,18 +91,33 @@ module.exports = function(grunt) {
7391
grunt.registerTask('default', 'lint qunit');
7492

7593
// Legacy multtask
76-
grunt.registerMultiTask('legacy', 'support for old build targets', function() {
77-
var util = require('util'),
78-
exec = require('child_process').exec,
79-
done = this.async();
94+
grunt.registerMultiTask('legacy_tasks', 'support for old build targets', function() {
95+
var done = this.async(), name = this.name, self = this;
8096

81-
exec("make " + this.target, function (error, stdout, stderr) {
82-
if( stderr || error ){
83-
grunt.log.error( stderr || error );
97+
(this.data.deps || [] ).forEach(function( dep) {
98+
self.requires( 'legacy_tasks:' + dep );
99+
});
100+
101+
child_process.exec( (this.data.env || "") + " bash build/bin/" + this.target + ".sh", function (error, stdout, stderr) {
102+
if( error !== null ){
103+
grunt.log.error( stderr );
104+
} else {
105+
grunt.log.write(stdout);
84106
}
85107

86-
grunt.log.write(stdout);
87108
done();
88109
});
89110
});
111+
112+
// register the task alias's to enforce task dependencies
113+
var tasks = grunt.config.get('legacy_tasks');
114+
for( task in tasks ){
115+
var deps = [];
116+
117+
(tasks[task].deps || []).forEach(function( dep ) {
118+
deps.push("legacy_tasks:" + dep);
119+
});
120+
121+
grunt.registerTask( 'legacy:' + task, deps.join(" ") + " legacy_tasks:" + task );
122+
}
90123
};

0 commit comments

Comments
 (0)