From c0bc03dc0b9e7fc3a0d47344ef8c0ad12f3cdc39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominykas=20Blyz=CC=8Ce=CC=87?= Date: Thu, 5 Nov 2015 13:50:58 +0200 Subject: [PATCH 1/4] be up to date --- .travis.yml | 7 +++++++ package.json | 17 +++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 587bd3e..52f3758 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1 +1,8 @@ language: node_js +node_js: + - "0.10" + - "0.12" + - "4" + - "5" +before_install: + - npm i -g npm diff --git a/package.json b/package.json index c31f8f5..0e121b1 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "license": "MIT", "main": "./tasks/buster.js", "engines": { - "node": ">= 0.8.0" + "node": ">= 0.10" }, "scripts": { "start": "grunt --force default watch", @@ -25,17 +25,18 @@ }, "devDependencies": { "buster": ">=0.7.6", - "grunt": "~0.4.1", - "grunt-cli": "~0.1.8", - "grunt-contrib-jshint": "~0.10.0", - "grunt-contrib-watch": "~0.4.0" + "grunt": "^0.4.1", + "grunt-cli": "^0.1.8", + "grunt-contrib-jshint": "^0.11.3", + "grunt-contrib-watch": "^0.6.1" }, "dependencies": { - "when": "~2.0.0", - "resolve-bin": "~0.3.0" + "resolve-bin": "^0.3.0", + "when": "^3.7.4", + "which": "^1.2.0" }, "peerDependencies": { - "buster": ">=0.7.x", + "buster": ">=0.7.6", "grunt": "~0.4.0" }, "keywords": [ From 3a85ad7e3c47fe25d41e0526d3e57aa3acb5e167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominykas=20Blyz=CC=8Ce=CC=87?= Date: Thu, 5 Nov 2015 14:04:53 +0200 Subject: [PATCH 2/4] when unable to find a node_modules installed executable, look for it in PATH --- tasks/buster/cmd.js | 15 +++++++++++++-- test/cmd-test.js | 12 +++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/tasks/buster/cmd.js b/tasks/buster/cmd.js index 26004a0..f3888d5 100644 --- a/tasks/buster/cmd.js +++ b/tasks/buster/cmd.js @@ -2,10 +2,21 @@ var cp = require('child_process'); var grunt = require('grunt'); var when = require('when'); var resolveBin = require('resolve-bin'); +var which = require('which'); + +var findExecutable = function (moduleName, cmd, cb) { + resolveBin(moduleName, {executable:cmd}, function (error, path) { + if (error) { // failed to find in [global/local] node_modules - fallback to PATH + which(cmd, cb); + } else { + cb(null, path); + } + }); +}; exports.run = function (moduleName, cmd, args, callback) { callback = callback || function () {}; - resolveBin(moduleName, { executable: cmd }, function (error, path) { + findExecutable(moduleName, cmd, function (error, path) { if (error) { callback(error); } else { @@ -103,7 +114,7 @@ exports.runPhantomjs = function (args) { exports.run('phantomjs', 'phantomjs', args, function (error, phantomProcess) { if (error) { grunt.log.error( - 'PhantomJS not found. Run `npm install phantomjs` to install.'); + 'PhantomJS not found. Run `npm install [-g] phantomjs` to install.'); deferred.reject(); } else { phantomProcess.stdout.on('data', function (data) { diff --git a/test/cmd-test.js b/test/cmd-test.js index 826b74f..3bea073 100644 --- a/test/cmd-test.js +++ b/test/cmd-test.js @@ -26,10 +26,20 @@ buster.testCase('Cmd', { }); }, + 'calls callback with results when a global binary found': function (done) { + var spawnStub = this.spawnStub; + cmd.run('node', 'node', [ 1, 2, 3 ], function (err) { + assert.isNull(err); + // node is the only executable I can trust to be in actual PATH - I just dont' know that path, but there should definitely be no error + assert.calledOnce(spawnStub); + done(); + }); + }, + 'calls callback with error when resolve-bin fails': function (done) { cmd.run('no-such-module', 'no-such-file', [], function (err, actualHandle) { refute.isNull(err); - assert.match(err.message, 'cannot find'); + assert.match(err.message, 'not found'); refute(actualHandle); done(); }); From adcdff3c0b02ca447f96343021576b1ac75e3ebf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominykas=20Blyz=CC=8Ce=CC=87?= Date: Thu, 5 Nov 2015 14:19:49 +0200 Subject: [PATCH 3/4] upgrade travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 52f3758..896e270 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: node_js +sudo: false node_js: - "0.10" - "0.12" From ae694e228852d680c5413e8479da839bbf88c1d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominykas=20Blyz=CC=8Ce=CC=87?= Date: Tue, 10 Nov 2015 21:23:55 +0200 Subject: [PATCH 4/4] a better way of versioning deps --- package.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 0e121b1..23c4913 100644 --- a/package.json +++ b/package.json @@ -17,27 +17,27 @@ "license": "MIT", "main": "./tasks/buster.js", "engines": { - "node": ">= 0.10" + "node": ">= 4" }, "scripts": { "start": "grunt --force default watch", "test": "grunt" }, "devDependencies": { - "buster": ">=0.7.6", - "grunt": "^0.4.1", - "grunt-cli": "^0.1.8", - "grunt-contrib-jshint": "^0.11.3", - "grunt-contrib-watch": "^0.6.1" + "buster": "0.7.x", + "grunt": "0.4.x", + "grunt-cli": "0.1.x", + "grunt-contrib-jshint": "0.11.x", + "grunt-contrib-watch": "0.6.x" }, "dependencies": { - "resolve-bin": "^0.3.0", - "when": "^3.7.4", - "which": "^1.2.0" + "resolve-bin": "0.3.x", + "when": "3.x", + "which": "1.x" }, "peerDependencies": { "buster": ">=0.7.6", - "grunt": "~0.4.0" + "grunt": ">=0.4.0" }, "keywords": [ "gruntplugin",