|
7 | 7 |
|
8 | 8 | /*jshint node: true */ |
9 | 9 | /*global config:true, task:true, process:true*/ |
| 10 | + |
| 11 | +var child_process = require("child_process"); |
| 12 | + |
10 | 13 | module.exports = function( grunt ) { |
11 | 14 |
|
12 | 15 | // readOptionalJSON |
@@ -379,22 +382,29 @@ module.exports = function( grunt ) { |
379 | 382 | }); |
380 | 383 |
|
381 | 384 | grunt.registerTask( "submodules", function() { |
382 | | - var done = this.async(); |
| 385 | + var done = this.async(), |
| 386 | + // change pointers for submodules and update them to what is specified in jQuery |
| 387 | + // --merge doesn't work when doing an initial clone, thus test if we have non-existing |
| 388 | + // submodules, then do an real update |
| 389 | + cmd = "if [ -d .git ]; then \n" + |
| 390 | + "if git submodule status | grep -q -E '^-'; then \n" + |
| 391 | + "git submodule update --init --recursive; \n" + |
| 392 | + "else \n" + |
| 393 | + "git submodule update --init --recursive --merge; \n" + |
| 394 | + "fi; \n" + |
| 395 | + "fi;"; |
383 | 396 |
|
384 | 397 | grunt.verbose.write( "Updating submodules..." ); |
385 | 398 |
|
386 | | - // TODO: migrate remaining `make` to grunt tasks |
387 | | - // |
388 | | - grunt.utils.spawn({ |
389 | | - cmd: "make" |
390 | | - }, function( err, result ) { |
391 | | - if ( err ) { |
| 399 | + child_process.exec( cmd, function( err, stdout, stderr ) { |
| 400 | + if ( stderr ) { |
| 401 | + console.log(stderr); |
392 | 402 | grunt.verbose.error(); |
393 | | - done( err ); |
| 403 | + done( stderr ); |
394 | 404 | return; |
395 | 405 | } |
396 | 406 |
|
397 | | - grunt.log.writeln( result ); |
| 407 | + grunt.log.writeln( stdout ); |
398 | 408 |
|
399 | 409 | done(); |
400 | 410 | }); |
|
0 commit comments