Comparing version 0.0.5-pre2 to 0.0.5-pre3
@@ -1,12 +0,29 @@ | ||
{ "name": "shelljs" | ||
, "version": "0.0.5pre2" | ||
, "author": "Artur Adib <aadib@mozilla.com>" | ||
, "description": "Portable Unix shell commands for Node.js" | ||
, "keywords": ["unix", "shell", "makefile", "make", "jake", "synchronous"] | ||
, "repository": "git://github.com/arturadib/shelljs" | ||
, "homepage": "http://github.com/arturadib/shelljs" | ||
, "main": "./shell.js" | ||
, "scripts": { | ||
{ | ||
"name": "shelljs", | ||
"version": "0.0.5pre3", | ||
"author": "Artur Adib <aadib@mozilla.com>", | ||
"description": "Portable Unix shell commands for Node.js", | ||
"keywords": [ | ||
"unix", | ||
"shell", | ||
"makefile", | ||
"make", | ||
"jake", | ||
"synchronous" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/arturadib/shelljs.git" | ||
}, | ||
"homepage": "http://github.com/arturadib/shelljs", | ||
"main": "./shell.js", | ||
"scripts": { | ||
"test": "node scripts/run-tests" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": {}, | ||
"optionalDependencies": {}, | ||
"engines": { | ||
"node": "*" | ||
} | ||
} |
33
shell.js
@@ -1023,3 +1023,3 @@ // | ||
// If state.error hasn't been set it's an error thrown by Node, not us - probably a bug... | ||
console.log('maker.js: internal error'); | ||
console.log('shell.js: internal error'); | ||
console.log(e.stack || e); | ||
@@ -1032,3 +1032,3 @@ process.exit(1); | ||
state.currentCmd = 'maker.js'; | ||
state.currentCmd = 'shell.js'; | ||
return retValue; | ||
@@ -1156,4 +1156,3 @@ } | ||
} catch(e) { | ||
if (e.code === 'ENOTEMPTY') | ||
error('directory not empty: ' + dir, true); | ||
error('could not remove directory (code '+e.code+'): ' + dir, true); | ||
} | ||
@@ -1240,4 +1239,7 @@ | ||
function execAsync(cmd, opts, callback) { | ||
var output = '', | ||
silent = 'silent' in opts ? opts.silent : state.silent; | ||
var output = ''; | ||
var options = extend({ | ||
silent: state.silent | ||
}, opts); | ||
@@ -1251,4 +1253,4 @@ var c = child.exec(cmd, {env: process.env}, function(err) { | ||
output += data; | ||
if (!silent) | ||
write(data); | ||
if (!options.silent) | ||
process.stdout.write(data); | ||
}); | ||
@@ -1258,4 +1260,4 @@ | ||
output += data; | ||
if (!silent) | ||
write(data); | ||
if (!options.silent) | ||
process.stdout.write(data); | ||
}); | ||
@@ -1334,7 +1336,8 @@ } | ||
_unlinkSync(scriptFile); | ||
_unlinkSync(stdoutFile); | ||
_unlinkSync(codeFile); | ||
_unlinkSync(sleepFile); | ||
// No biggie if we can't erase the files now -- they're in a temp dir anyway | ||
try { _unlinkSync(scriptFile); } catch(e) {}; | ||
try { _unlinkSync(stdoutFile); } catch(e) {}; | ||
try { _unlinkSync(codeFile); } catch(e) {}; | ||
try { _unlinkSync(sleepFile); } catch(e) {}; | ||
// True if successful, false if not | ||
@@ -1341,0 +1344,0 @@ var obj = { |
@@ -5,3 +5,4 @@ var shell = require('..'); | ||
path = require('path'), | ||
fs = require('fs'); | ||
fs = require('fs'), | ||
child = require('child_process'); | ||
@@ -29,3 +30,8 @@ shell.silent(true); | ||
var result = shell.exec('node -e \"console.log(1234);\"'); // stdout | ||
// | ||
// sync | ||
// | ||
// check if stdout goes to output | ||
var result = shell.exec('node -e \"console.log(1234);\"'); | ||
assert.equal(shell.error(), null); | ||
@@ -35,12 +41,10 @@ assert.equal(result.code, 0); | ||
var result = shell.exec('node -e \"process.exit(12);\"'); // stdout | ||
// check if stderr goes to output | ||
var result = shell.exec('node -e \"console.error(1234);\"'); | ||
assert.equal(shell.error(), null); | ||
assert.equal(result.code, 12); | ||
var result = shell.exec('node -e \"console.error(1234);\"'); // stderr | ||
assert.equal(shell.error(), null); | ||
assert.equal(result.code, 0); | ||
assert.ok(result.output === '1234\n' || result.output === '1234\nundefined\n'); // 'undefined' for v0.4 | ||
var result = shell.exec('node -e \"console.error(1234); console.log(666);\"'); // stderr + stdout | ||
// check if stdout + stderr go to output | ||
var result = shell.exec('node -e \"console.error(1234); console.log(666);\"'); | ||
assert.equal(shell.error(), null); | ||
@@ -50,3 +54,8 @@ assert.equal(result.code, 0); | ||
// Interaction with cd | ||
// check exit code | ||
var result = shell.exec('node -e \"process.exit(12);\"'); | ||
assert.equal(shell.error(), null); | ||
assert.equal(result.code, 12); | ||
// interaction with cd | ||
shell.cd('resources/external'); | ||
@@ -57,15 +66,62 @@ var result = shell.exec('node node_script.js'); | ||
assert.equal(result.output, 'node_script_1234\n'); | ||
shell.cd('../..'); | ||
// Async | ||
// | ||
// async | ||
// | ||
var asyncFlags = []; | ||
// | ||
// callback as 2nd argument | ||
// | ||
asyncFlags[0] = false; | ||
shell.exec('node -e \"console.log(1234);\"', {async:true}, function(code, output) { // callback as 2nd argument | ||
shell.exec('node -e \"console.log(5678);\"', {async:true}, function(code, output) { | ||
assert.equal(code, 0); | ||
assert.ok(output === '1234\n' || output === '1234\nundefined\n'); // 'undefined' for v0.4 | ||
assert.ok(output === '5678\n' || output === '5678\nundefined\n'); // 'undefined' for v0.4 | ||
asyncFlags[0] = true; | ||
// | ||
// check if stdout is proxied with default silent options (i.e. silent = false) | ||
// | ||
asyncFlags[1] = false; | ||
shell.mkdir('-p', 'tmp'); | ||
var file = 'tmp/tempscript'+Math.random()+'.js', | ||
script = 'require(\'../../global.js\'); exec(\'node -e \"console.log(555);\"\')'; | ||
script.to(file); | ||
child.exec('node '+file, function(err, stdout, stderr) { | ||
assert.ok(stdout === '555\n' || stdout === '555\nundefined\n'); // 'undefined' for v0.4 | ||
asyncFlags[1] = true; | ||
// | ||
// check if stdout is proxied when: silent(true), {silent:false} | ||
// | ||
asyncFlags[2] = false; | ||
shell.mkdir('-p', 'tmp'); | ||
var file = 'tmp/tempscript'+Math.random()+'.js', | ||
script = 'require(\'../../global.js\'); silent(true); exec(\'node -e \"console.log(333);\"\', {silent:false})'; | ||
script.to(file); | ||
child.exec('node '+file, function(err, stdout, stderr) { | ||
assert.ok(stdout === '333\n' || stdout === '333\nundefined\n'); // 'undefined' for v0.4 | ||
asyncFlags[2] = true; | ||
// | ||
// check if stdout is proxied when: silent(true), {silent:false} - async | ||
// | ||
asyncFlags[3] = false; | ||
shell.mkdir('-p', 'tmp'); | ||
var file = 'tmp/tempscript'+Math.random()+'.js', | ||
script = 'require(\'../../global.js\'); silent(true); exec(\'node -e \"console.log(222);\"\', {silent:false, async:true})'; | ||
script.to(file); | ||
child.exec('node '+file, function(err, stdout, stderr) { | ||
assert.ok(stdout === '222\n' || stdout === '222\nundefined\n'); // 'undefined' for v0.4 | ||
asyncFlags[3] = true; | ||
}); | ||
}); | ||
}); | ||
}); | ||
assert.equal(shell.error(), null); | ||
shell.exec('node -e \"console.log(1234)\"', {async:true}); // no callback | ||
// no callback (no need for asyncFlags) | ||
shell.exec('node -e \"console.log(1234)\"', {async:true}); | ||
assert.equal(shell.error(), null); | ||
@@ -72,0 +128,0 @@ |
@@ -36,17 +36,35 @@ var shell = require('..'); | ||
shell.rm('-f', 'asdfasdf'); // file does not exist, but -f specified | ||
// file does not exist, but -f specified | ||
shell.rm('-f', 'asdfasdf'); | ||
assert.equal(shell.error(), null); | ||
shell.cp('-f', 'resources/file1', 'tmp/file1'); | ||
// simple rm | ||
shell.cp('-f', 'resources/file1', 'tmp/file1'); | ||
assert.equal(fs.existsSync('tmp/file1'), true); | ||
shell.rm('tmp/file1'); // simple rm | ||
shell.rm('tmp/file1'); | ||
assert.equal(shell.error(), null); | ||
assert.equal(fs.existsSync('tmp/file1'), false); | ||
// recursive dir removal - small-caps '-r' | ||
shell.mkdir('-p', 'tmp/a/b/c'); | ||
assert.equal(fs.existsSync('tmp/a/b/c'), true); | ||
shell.rm('-rf', 'tmp/a'); // recursive dir removal | ||
shell.rm('-rf', 'tmp/a'); | ||
assert.equal(shell.error(), null); | ||
assert.equal(fs.existsSync('tmp/a'), false); | ||
// recursive dir removal - capital '-R' | ||
shell.mkdir('-p', 'tmp/a/b/c'); | ||
assert.equal(fs.existsSync('tmp/a/b/c'), true); | ||
shell.rm('-Rf', 'tmp/a'); | ||
assert.equal(shell.error(), null); | ||
assert.equal(fs.existsSync('tmp/a'), false); | ||
// recursive dir removal - absolute path | ||
shell.mkdir('-p', 'tmp/a/b/c'); | ||
assert.equal(fs.existsSync('tmp/a/b/c'), true); | ||
shell.rm('-Rf', path.resolve('./tmp/a')); | ||
assert.equal(shell.error(), null); | ||
assert.equal(fs.existsSync('tmp/a'), false); | ||
// wildcard | ||
shell.cp('-f', 'resources/file*', 'tmp'); | ||
@@ -53,0 +71,0 @@ assert.equal(shell.error(), null); |
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
89956
60
2334
31
3