gulp-shell
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -23,6 +23,7 @@ var _ = require('lodash') | ||
var pathToBin = join(__dirname, 'node_modules', '.bin') | ||
var pathToBin = join(process.cwd(), 'node_modules/.bin') | ||
var separator = process.platform.match(/^win/) >= 0 ? ';' : ':' | ||
var path = pathToBin + separator + process.env.PATH | ||
var env = _.extend({}, process.env, {PATH: path}) | ||
var cwd = options.cwd || process.cwd() | ||
@@ -35,3 +36,3 @@ return through.obj(function (file, _, done) { | ||
cp.exec(command, {env: env}, function (error, stdout, stderr) { | ||
cp.exec(command, {env: env, cwd: cwd}, function (error, stdout, stderr) { | ||
if (!quiet) { | ||
@@ -38,0 +39,0 @@ if (stderr) gutil.log(stderr.trim()) |
{ | ||
"name": "gulp-shell", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "A handy command line interface for gulp", | ||
@@ -9,3 +9,3 @@ "main": "index.js", | ||
"watch": "mocha -R spec -r should -w", | ||
"coverage": "istanbul cover _mocha --report lcovonly -- -R spec", | ||
"coverage": "istanbul cover _mocha -- -R spec", | ||
"coveralls": "npm run coverage && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage" | ||
@@ -12,0 +12,0 @@ }, |
@@ -81,1 +81,9 @@ # gulp-shell | ||
By default, it will print the command output. | ||
#### options.cwd | ||
type: `String` | ||
default: Result of `process.cwd()` (as described [here](http://nodejs.org/api/process.html#process_process_cwd)) | ||
Sets the current working directory for the command. |
@@ -7,2 +7,11 @@ var gutil = require('gulp-util') | ||
var originalStdoutWrite = process.stdout.write | ||
function shouldOutput(expected, done) { | ||
process.stdout.write = function (actual) { | ||
process.stdout.write = originalStdoutWrite | ||
should(actual).containEql(expected) | ||
done() | ||
} | ||
} | ||
describe('gulp-shell(commands, options)', function () { | ||
@@ -37,8 +46,3 @@ var fakeFile = new gutil.File({ | ||
var write = process.stdout.write | ||
process.stdout.write = function (output) { | ||
process.stdout.write = write | ||
should(output).containEql(fakeFile.path) | ||
done() | ||
} | ||
shouldOutput(fakeFile.path, done) | ||
@@ -51,8 +55,3 @@ stream.write(fakeFile) | ||
var write = process.stdout.write | ||
process.stdout.write = function (output) { | ||
process.stdout.write = write | ||
should(output).containEql(join(__dirname, '..', 'node_modules', '.bin')) | ||
done() | ||
} | ||
shouldOutput(join(process.cwd(), 'node_modules/.bin'), done) | ||
@@ -105,10 +104,6 @@ stream.write(fakeFile) | ||
var write = process.stdout.write | ||
process.stdout.write = function () { | ||
process.stdout.write = write | ||
throw new Error() | ||
} | ||
shouldOutput('this should not match anything!', done) | ||
stream.on('data', function () { | ||
process.stdout.write = write | ||
process.stdout.write = originalStdoutWrite | ||
done() | ||
@@ -120,3 +115,24 @@ }) | ||
}) | ||
describe('cwd', function () { | ||
it('should set the current working directory when `cwd` is a string', function (done) { | ||
var stream = shell(['pwd'], {cwd: '..'}) | ||
shouldOutput(join(__dirname, '../..'), done) | ||
stream.write(fakeFile) | ||
}) | ||
}) | ||
describe('cwd', function () { | ||
it('should use the process current working directory when `cwd` is not passed', function (done) { | ||
var stream = shell(['pwd']) | ||
shouldOutput(join(__dirname, '..'), done) | ||
stream.write(fakeFile) | ||
}) | ||
}) | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9806
151
89