From 9944e660edd45ed3b1a80b16ea210572603adfde Mon Sep 17 00:00:00 2001 From: Jussi Kalliokoski Date: Sat, 4 Apr 2015 01:11:06 +0300 Subject: [PATCH] :art: :green_heart: Fixed the test script. Also removed duplicated logic to run grunt. --- script/build | 7 +++---- script/grunt | 19 ++++--------------- script/test | 4 ++-- script/utils/run-grunt.js | 17 +++++++++++++++++ 4 files changed, 26 insertions(+), 21 deletions(-) create mode 100644 script/utils/run-grunt.js diff --git a/script/build b/script/build index 1f0f123ce..a40a02e13 100755 --- a/script/build +++ b/script/build @@ -1,13 +1,12 @@ #!/usr/bin/env node var cp = require('./utils/child-process-wrapper.js'); +var runGrunt = require('./utils/run-grunt.js'); var path = require('path'); process.chdir(path.dirname(__dirname)); cp.safeExec('node script/bootstrap', function() { // build/node_modules/.bin/grunt "$@" - var gruntPath = path.join('build', 'node_modules', '.bin', 'grunt') + (process.platform === 'win32' ? '.cmd' : ''); - var args = ['--gruntfile', path.resolve('build', 'Gruntfile.coffee')]; - args = args.concat(process.argv.slice(2)); - cp.safeSpawn(gruntPath, args, process.exit); + var args = process.argv.slice(2); + runGrunt(args, process.exit); }); diff --git a/script/grunt b/script/grunt index 23b12cf85..99f6860d2 100755 --- a/script/grunt +++ b/script/grunt @@ -1,17 +1,6 @@ #!/usr/bin/env node -var cp = require('./utils/child-process-wrapper.js'); -var fs = require('fs'); -var path = require('path'); +var runGrunt = require('./utils/run-grunt.js'); -// node build/node_modules/.bin/grunt "$@" -var gruntPath = path.resolve(__dirname, '..', 'build', 'node_modules', '.bin', 'grunt') + (process.platform === 'win32' ? '.cmd' : ''); - -if (!fs.existsSync(gruntPath)) { - console.error('Grunt command does not exist at: ' + gruntPath); - console.error('Run script/bootstrap to install Grunt'); - process.exit(1); -} - -var args = ['--gruntfile', path.resolve('build', 'Gruntfile.coffee')]; -args = args.concat(process.argv.slice(2)); -cp.safeSpawn(gruntPath, args, process.exit); +// build/node_modules/.bin/grunt "$@" +var args = process.argv.slice(2); +runGrunt(args, process.exit); diff --git a/script/test b/script/test index 2c3b37147..e8cb53006 100755 --- a/script/test +++ b/script/test @@ -1,10 +1,10 @@ #!/usr/bin/env node var safeExec = require('./utils/child-process-wrapper.js').safeExec; +var runGrunt = require('./utils/run-grunt.js'); var path = require('path'); process.chdir(path.dirname(__dirname)); safeExec('node script/bootstrap', function() { - var gruntPath = path.join('node_modules', '.bin', 'grunt') + (process.platform === 'win32' ? '.cmd' : ''); - safeExec(gruntPath + ' ci --stack --no-color', process.exit); + runGrunt(["ci", "--stack", "--no-color"], process.exit); }); diff --git a/script/utils/run-grunt.js b/script/utils/run-grunt.js new file mode 100644 index 000000000..f63d1009a --- /dev/null +++ b/script/utils/run-grunt.js @@ -0,0 +1,17 @@ +var cp = require('./child-process-wrapper.js'); +var fs = require('fs'); +var path = require('path'); + +module.exports = function(additionalArgs, callback) { + var gruntPath = path.join('build', 'node_modules', '.bin', 'grunt') + (process.platform === 'win32' ? '.cmd' : ''); + + if (!fs.existsSync(gruntPath)) { + console.error('Grunt command does not exist at: ' + gruntPath); + console.error('Run script/bootstrap to install Grunt'); + process.exit(1); + } + + var args = ['--gruntfile', path.resolve('build', 'Gruntfile.coffee')]; + args = args.concat(additionalArgs); + cp.safeSpawn(gruntPath, args, callback); +};