diff --git a/.travis.yml b/.travis.yml index 4a83e22..18ae2d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,4 +2,3 @@ language: node_js node_js: - "0.11" - "0.10" - - "0.8" diff --git a/Gruntfile.js b/Gruntfile.js index d751f0b..372fcc6 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -87,6 +87,12 @@ module.exports = function (grunt) { }, src: ['test/fixtures/module.async.js'] }, + harmony_on: { + options: { + nodeargs: ['--harmony'] + }, + src: ['test/fixtures/node.harmony.js'] + }, call_sync: { call: function (grunt, options, async) { var ctx = help.getContext('call.sync.gruntfile.js'); @@ -167,6 +173,7 @@ module.exports = function (grunt) { 'execute:node_args', 'execute:node_async', 'execute:node_sync', + 'execute:harmony_on', 'execute:zero', 'execute:module_sync', 'execute:module_async', diff --git a/README.md b/README.md index e93fd09..fc51ef1 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,13 @@ grunt.initConfig({ }, src: ['script.js'] }, + simple_target_with_harmony: { + options: { + // pass arguments to node itself (eg: before script parameter) + nodeargs: ['--harmony'] + }, + src: ['script.js'] + }, cwd_target: { options: { // overide code cwd (defaults to '.' for project main) @@ -127,7 +134,8 @@ grunt.initConfig({ ## Versions -* 0.2.1 - Non-zero exit code will fail grunt, add support for commandline arguments +* 0.2.2 - Add support for node arguments, via `nodeargs` (like `--harmony`) +* 0.2.1 - Non-zero exit code will fail grunt, add support for commandline arguments * 0.1.5 - Added callback module & inline function support * 0.1.4 - Ditched stdio option, show errors inline (even in webstorm) * 0.1.3 - Basic version, colors disabled diff --git a/package.json b/package.json index c56d0eb..f5dc38a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "grunt-execute", "description": "Execute code in node", - "version": "0.2.1", + "version": "0.2.2", "homepage": "https://github.com/Bartvds/grunt-execute", "author": { "name": "Bart van der Schoor", diff --git a/tasks/execute.js b/tasks/execute.js index 18719da..71e4235 100644 --- a/tasks/execute.js +++ b/tasks/execute.js @@ -123,11 +123,16 @@ module.exports = function (grunt) { var start = Date.now(); + var args = context.options.args ? [src].concat(context.options.args) : [src]; + if (context.options.nodeargs) { + args = context.options.nodeargs.concat(args); + } + //use spawn so we don't have to depend on process.exit(); var child = grunt.util.spawn( { cmd: 'node', - args: context.options.args ? [src].concat(context.options.args) : [src], + args: args, opts: { cwd: (context.options.cwd !== null) ? context.options.cwd : path.dirname(src) } diff --git a/test/execute_test.js b/test/execute_test.js index 0293e46..d05af67 100644 --- a/test/execute_test.js +++ b/test/execute_test.js @@ -48,8 +48,14 @@ exports.execute = { test.done(); }, args: function (test) { - test.expect(1); - easyTestOutput(test, 'node.args.js', ' foo bar'); + if (process.version.match(/^v\d+\.(\d+)\.\d+$/)[1] >= 11) { + test.expect(2); + easyTestOutput(test, 'node.args.js', ' foo bar'); + easyTestOutput(test, 'node.harmony.js', ' true'); + } else { + test.expect(1); + easyTestOutput(test, 'node.args.js', ' foo bar'); + } test.done(); }, module_sync: function (test) { diff --git a/test/fixtures/node.harmony.js b/test/fixtures/node.harmony.js new file mode 100644 index 0000000..4a63694 --- /dev/null +++ b/test/fixtures/node.harmony.js @@ -0,0 +1,10 @@ +var help = require('../helper.js'); +var ctx = help.getContext(__filename); + +var fs = require('fs'); + +setTimeout(function () { + fs.writeFile(ctx.dest, ctx.data + ' ' + ('function' === typeof Map), function (err) { + if(err) throw err; + }); +}, 100);