shelljs
Advanced tools
Comparing version 0.7.4 to 0.7.5
# Change Log | ||
## [Unreleased](https://github.com/shelljs/shelljs/tree/HEAD) | ||
[Full Changelog](https://github.com/shelljs/shelljs/compare/v0.7.4...HEAD) | ||
**Closed issues:** | ||
- Project objectives: there is some higher goal to achieve? [\#533](https://github.com/shelljs/shelljs/issues/533) | ||
- fs.existsSync is un-deprecated [\#531](https://github.com/shelljs/shelljs/issues/531) | ||
- Inadvertent breaking change to shell.test\(\) [\#529](https://github.com/shelljs/shelljs/issues/529) | ||
- Add -u flag support for cp [\#526](https://github.com/shelljs/shelljs/issues/526) | ||
- API request: allow `plugin.error\(\)` to take an options parameter [\#522](https://github.com/shelljs/shelljs/issues/522) | ||
- FS Real Path error thrown when requiring shelljs [\#521](https://github.com/shelljs/shelljs/issues/521) | ||
- Question: passing code via pipe? [\#520](https://github.com/shelljs/shelljs/issues/520) | ||
- The performance in `cp` is different between `0.6.0` and `0.7.4` [\#517](https://github.com/shelljs/shelljs/issues/517) | ||
- ShellJS in Electron package don't find ffmpeg anymore [\#516](https://github.com/shelljs/shelljs/issues/516) | ||
- Exec issues with string option introduced in 0.7.4 [\#515](https://github.com/shelljs/shelljs/issues/515) | ||
- \[ Feature \] SSH command [\#435](https://github.com/shelljs/shelljs/issues/435) | ||
- Synchronous exec stalls permenantly when there is an error/w the shell [\#7](https://github.com/shelljs/shelljs/issues/7) | ||
**Merged pull requests:** | ||
- feat: plugin.error\(\) takes an options parameter [\#535](https://github.com/shelljs/shelljs/pull/535) ([nfischer](https://github.com/nfischer)) | ||
- Revert "refactor: replace fs.existsSync" fixes\(\#531\) [\#532](https://github.com/shelljs/shelljs/pull/532) ([gyandeeps](https://github.com/gyandeeps)) | ||
- Fix: Remove default glob from shell.test \(fixes \#529\) [\#530](https://github.com/shelljs/shelljs/pull/530) ([gyandeeps](https://github.com/gyandeeps)) | ||
- feat: cp -u option [\#527](https://github.com/shelljs/shelljs/pull/527) ([nfischer](https://github.com/nfischer)) | ||
- chore: add downloads per month on README [\#513](https://github.com/shelljs/shelljs/pull/513) ([nfischer](https://github.com/nfischer)) | ||
## [v0.7.4](https://github.com/shelljs/shelljs/tree/v0.7.4) (2016-08-26) | ||
[Full Changelog](https://github.com/shelljs/shelljs/compare/v0.7.3...v0.7.4) | ||
**Closed issues:** | ||
- fix: echo -e should not print "-e" [\#510](https://github.com/shelljs/shelljs/issues/510) | ||
- Wrong method signature in doc [\#498](https://github.com/shelljs/shelljs/issues/498) | ||
- readFromPipe should be a function with no arguments [\#485](https://github.com/shelljs/shelljs/issues/485) | ||
- TypeError: Cannot read property 'toString' of undefined [\#471](https://github.com/shelljs/shelljs/issues/471) | ||
**Merged pull requests:** | ||
- fix: echo supports -e option properly [\#511](https://github.com/shelljs/shelljs/pull/511) ([nfischer](https://github.com/nfischer)) | ||
- refactor: replace fs.existsSync [\#509](https://github.com/shelljs/shelljs/pull/509) ([nfischer](https://github.com/nfischer)) | ||
- refactor: readFromPipe\(\) requires no arguments [\#506](https://github.com/shelljs/shelljs/pull/506) ([nfischer](https://github.com/nfischer)) | ||
- chore: switch to eslint [\#504](https://github.com/shelljs/shelljs/pull/504) ([nfischer](https://github.com/nfischer)) | ||
- feat: add overWrite option for commands [\#503](https://github.com/shelljs/shelljs/pull/503) ([nfischer](https://github.com/nfischer)) | ||
- chore: update issue template [\#502](https://github.com/shelljs/shelljs/pull/502) ([nfischer](https://github.com/nfischer)) | ||
- fixed head/tail readme [\#499](https://github.com/shelljs/shelljs/pull/499) ([charlesread](https://github.com/charlesread)) | ||
## [v0.7.3](https://github.com/shelljs/shelljs/tree/v0.7.3) (2016-07-27) | ||
@@ -202,2 +249,3 @@ [Full Changelog](https://github.com/shelljs/shelljs/compare/v0.7.2...v0.7.3) | ||
- By default shelljs runs command in root [\#246](https://github.com/shelljs/shelljs/issues/246) | ||
- /usr/bin/env: node: No such file or directory [\#243](https://github.com/shelljs/shelljs/issues/243) | ||
- "Which" command not working properly on Windows Platform. [\#238](https://github.com/shelljs/shelljs/issues/238) | ||
@@ -204,0 +252,0 @@ - Arguments [\#237](https://github.com/shelljs/shelljs/issues/237) |
{ | ||
"name": "shelljs", | ||
"version": "0.7.4", | ||
"version": "0.7.5", | ||
"description": "Portable Unix shell commands for Node.js", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -6,3 +6,4 @@ # ShellJS - Unix shell commands for Node.js | ||
[![AppVeyor](https://img.shields.io/appveyor/ci/shelljs/shelljs/master.svg?style=flat-square&label=windows)](https://ci.appveyor.com/project/shelljs/shelljs/branch/master) | ||
[![npm (scoped)](https://img.shields.io/npm/v/shelljs.svg?style=flat-square)](https://www.npmjs.com/package/shelljs) | ||
[![npm version](https://img.shields.io/npm/v/shelljs.svg?style=flat-square)](https://www.npmjs.com/package/shelljs) | ||
[![npm downloads](https://img.shields.io/npm/dm/shelljs.svg?style=flat-square)](https://www.npmjs.com/package/shelljs) | ||
@@ -214,2 +215,3 @@ ShellJS is a portable **(Windows/Linux/OS X)** implementation of Unix shell commands on top of the | ||
+ `-n`: no-clobber | ||
+ `-u`: only copy if source is newer than dest | ||
+ `-r`, `-R`: recursive | ||
@@ -216,0 +218,0 @@ + `-L`: follow symlinks |
@@ -31,3 +31,3 @@ var common = require('./common'); | ||
files.forEach(function (file) { | ||
if (!common.existsSync(file)) { | ||
if (!fs.existsSync(file)) { | ||
common.error('no such file or directory: ' + file); | ||
@@ -34,0 +34,0 @@ } |
@@ -105,3 +105,3 @@ var common = require('./common'); | ||
file = path.resolve(file); | ||
if (!common.existsSync(file)) { | ||
if (!fs.existsSync(file)) { | ||
common.error('File not found: ' + file); | ||
@@ -108,0 +108,0 @@ } |
@@ -10,3 +10,2 @@ // Ignore warning about 'new String()' | ||
var DEFAULT_ERROR_CODE = 1; | ||
var shellMethods = Object.create(shell); | ||
@@ -49,30 +48,35 @@ | ||
// Shows error message. Throws if config.fatal is true | ||
function error(msg, _code, _continue) { | ||
if (typeof _code === 'boolean') { | ||
_continue = _code; | ||
_code = DEFAULT_ERROR_CODE; | ||
} | ||
if (typeof _code !== 'number') { | ||
_code = DEFAULT_ERROR_CODE; | ||
} | ||
function error(msg, _code, options) { | ||
// Validate input | ||
if (typeof msg !== 'string') throw new Error('msg must be a string'); | ||
if (state.errorCode === 0) { | ||
state.errorCode = _code; | ||
} | ||
var DEFAULT_OPTIONS = { | ||
continue: false, | ||
code: 1, | ||
prefix: state.currentCmd + ': ', | ||
silent: false, | ||
}; | ||
if (state.error === null) { | ||
state.error = ''; | ||
if (typeof _code === 'number' && typeof options === 'object') { | ||
options.code = _code; | ||
} else if (typeof _code === 'object') { // no 'code' | ||
options = _code; | ||
} else if (typeof _code === 'number') { // no 'options' | ||
options = { code: _code }; | ||
} else if (typeof _code !== 'number') { // only 'msg' | ||
options = {}; | ||
} | ||
var logEntry = state.currentCmd + ': ' + msg; | ||
if (state.error === '') { | ||
state.error = logEntry; | ||
} else { | ||
state.error += '\n' + logEntry; | ||
} | ||
options = objectAssign({}, DEFAULT_OPTIONS, options); | ||
if (!state.errorCode) state.errorCode = options.code; | ||
var logEntry = options.prefix + msg; | ||
state.error = state.error ? state.error + '\n' : ''; | ||
state.error += logEntry; | ||
// Throw an error, or log the entry | ||
if (config.fatal) throw new Error(logEntry); | ||
if (msg.length > 0 && !options.silent) log(logEntry); | ||
if (msg.length > 0) log(logEntry); | ||
if (!_continue) { | ||
if (!options.continue) { | ||
throw { | ||
@@ -86,12 +90,2 @@ msg: 'earlyExit', | ||
function existsSync(file) { | ||
try { | ||
fs.statSync(file); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
exports.existsSync = existsSync; | ||
//@ | ||
@@ -98,0 +92,0 @@ //@ ### ShellString(str) |
@@ -10,2 +10,3 @@ var fs = require('fs'); | ||
'n': 'no_force', | ||
'u': 'update', | ||
'R': 'recursive', | ||
@@ -23,6 +24,15 @@ 'r': 'recursive', | ||
function copyFileSync(srcFile, destFile, options) { | ||
if (!common.existsSync(srcFile)) { | ||
if (!fs.existsSync(srcFile)) { | ||
common.error('copyFileSync: no such file or directory: ' + srcFile); | ||
} | ||
// Check the mtimes of the files if the '-u' flag is provided | ||
try { | ||
if (options.update && fs.statSync(srcFile).mtime < fs.statSync(destFile).mtime) { | ||
return; | ||
} | ||
} catch (e) { | ||
// If we're here, destFile probably doesn't exist, so just do a normal copy | ||
} | ||
if (fs.lstatSync(srcFile).isSymbolicLink() && !options.followsymlink) { | ||
@@ -140,3 +150,3 @@ try { | ||
/* At this point, we've hit a file actually worth copying... so copy it on over. */ | ||
if (common.existsSync(destFile) && opts.no_force) { | ||
if (fs.existsSync(destFile) && opts.no_force) { | ||
common.log('skipping existing file: ' + files[i]); | ||
@@ -179,2 +189,3 @@ } else { | ||
//@ + `-n`: no-clobber | ||
//@ + `-u`: only copy if source is newer than dest | ||
//@ + `-r`, `-R`: recursive | ||
@@ -211,3 +222,3 @@ //@ + `-L`: follow symlinks | ||
var destExists = common.existsSync(dest); | ||
var destExists = fs.existsSync(dest); | ||
var destStat = destExists && fs.statSync(dest); | ||
@@ -226,4 +237,4 @@ | ||
sources.forEach(function (src) { | ||
if (!common.existsSync(src)) { | ||
common.error('no such file or directory: ' + src, true); | ||
if (!fs.existsSync(src)) { | ||
common.error('no such file or directory: ' + src, { continue: true }); | ||
return; // skip file | ||
@@ -235,3 +246,3 @@ } | ||
// Non-Recursive | ||
common.error("omitting directory '" + src + "'", true); | ||
common.error("omitting directory '" + src + "'", { continue: true }); | ||
} else { | ||
@@ -261,3 +272,3 @@ // Recursive | ||
if (common.existsSync(thisDest) && options.no_force) { | ||
if (fs.existsSync(thisDest) && options.no_force) { | ||
return; // skip file | ||
@@ -264,0 +275,0 @@ } |
@@ -40,3 +40,3 @@ var common = require('./common'); | ||
function updateStream(streamFile) { | ||
if (opts.silent || !common.existsSync(streamFile)) { | ||
if (opts.silent || !fs.existsSync(streamFile)) { | ||
return; | ||
@@ -65,6 +65,6 @@ } | ||
if (common.existsSync(scriptFile)) common.unlinkSync(scriptFile); | ||
if (common.existsSync(stdoutFile)) common.unlinkSync(stdoutFile); | ||
if (common.existsSync(stderrFile)) common.unlinkSync(stderrFile); | ||
if (common.existsSync(codeFile)) common.unlinkSync(codeFile); | ||
if (fs.existsSync(scriptFile)) common.unlinkSync(scriptFile); | ||
if (fs.existsSync(stdoutFile)) common.unlinkSync(stdoutFile); | ||
if (fs.existsSync(stderrFile)) common.unlinkSync(stderrFile); | ||
if (fs.existsSync(codeFile)) common.unlinkSync(codeFile); | ||
@@ -139,5 +139,5 @@ var execCommand = JSON.stringify(process.execPath) + ' ' + JSON.stringify(scriptFile); | ||
// CPU usage, though apparently not so much on Windows) | ||
while (!common.existsSync(codeFile)) { updateStream(stdoutFile); fs.writeFileSync(sleepFile, 'a'); } | ||
while (!common.existsSync(stdoutFile)) { updateStream(stdoutFile); fs.writeFileSync(sleepFile, 'a'); } | ||
while (!common.existsSync(stderrFile)) { updateStream(stderrFile); fs.writeFileSync(sleepFile, 'a'); } | ||
while (!fs.existsSync(codeFile)) { updateStream(stdoutFile); fs.writeFileSync(sleepFile, 'a'); } | ||
while (!fs.existsSync(stdoutFile)) { updateStream(stdoutFile); fs.writeFileSync(sleepFile, 'a'); } | ||
while (!fs.existsSync(stderrFile)) { updateStream(stderrFile); fs.writeFileSync(sleepFile, 'a'); } | ||
try { common.unlinkSync(sleepFile); } catch (e) {} | ||
@@ -163,3 +163,3 @@ } | ||
if (code !== 0) { | ||
common.error('', code, true); | ||
common.error('', code, { continue: true }); | ||
} | ||
@@ -166,0 +166,0 @@ var obj = common.ShellString(stdout, stderr, code); |
@@ -44,4 +44,4 @@ var common = require('./common'); | ||
files.forEach(function (file) { | ||
if (!common.existsSync(file) && file !== '-') { | ||
common.error('no such file or directory: ' + file, 2, true); | ||
if (!fs.existsSync(file) && file !== '-') { | ||
common.error('no such file or directory: ' + file, 2, { continue: true }); | ||
return; | ||
@@ -48,0 +48,0 @@ } |
@@ -75,4 +75,4 @@ var common = require('./common'); | ||
files.forEach(function (file) { | ||
if (!common.existsSync(file) && file !== '-') { | ||
common.error('no such file or directory: ' + file, true); | ||
if (!fs.existsSync(file) && file !== '-') { | ||
common.error('no such file or directory: ' + file, { continue: true }); | ||
return; | ||
@@ -79,0 +79,0 @@ } |
@@ -37,5 +37,5 @@ var fs = require('fs'); | ||
if (common.existsSync(dest)) { | ||
if (fs.existsSync(dest)) { | ||
if (!options.force) { | ||
common.error('Destination file exists', true); | ||
common.error('Destination file exists', { continue: true }); | ||
} | ||
@@ -50,4 +50,4 @@ | ||
var resolvedSourcePath = isAbsolute ? sourcePath : path.resolve(process.cwd(), path.dirname(dest), source); | ||
if (!common.existsSync(resolvedSourcePath)) { | ||
common.error('Source file does not exist', true); | ||
if (!fs.existsSync(resolvedSourcePath)) { | ||
common.error('Source file does not exist', { continue: true }); | ||
} else if (isWindows && fs.statSync(resolvedSourcePath).isDirectory()) { | ||
@@ -63,4 +63,4 @@ linkType = 'junction'; | ||
} else { | ||
if (!common.existsSync(source)) { | ||
common.error('Source file does not exist', true); | ||
if (!fs.existsSync(source)) { | ||
common.error('Source file does not exist', { continue: true }); | ||
} | ||
@@ -67,0 +67,0 @@ try { |
@@ -77,3 +77,3 @@ var path = require('path'); | ||
} catch (e) { | ||
common.error('no such file or directory: ' + p, 2, true); | ||
common.error('no such file or directory: ' + p, 2, { continue: true }); | ||
return; | ||
@@ -80,0 +80,0 @@ } |
@@ -23,3 +23,3 @@ var common = require('./common'); | ||
// Base dir exists, no recursion necessary | ||
if (common.existsSync(baseDir)) { | ||
if (fs.existsSync(baseDir)) { | ||
fs.mkdirSync(dir, parseInt('0777', 8)); | ||
@@ -63,3 +63,3 @@ return; | ||
if (!options.fullpath) { | ||
common.error('path already exists: ' + dir, true); | ||
common.error('path already exists: ' + dir, { continue: true }); | ||
} | ||
@@ -73,4 +73,4 @@ return; // skip dir | ||
var baseDir = path.dirname(dir); | ||
if (!common.existsSync(baseDir) && !options.fullpath) { | ||
common.error('no such file or directory: ' + baseDir, true); | ||
if (!fs.existsSync(baseDir) && !options.fullpath) { | ||
common.error('no such file or directory: ' + baseDir, { continue: true }); | ||
return; // skip dir | ||
@@ -77,0 +77,0 @@ } |
@@ -44,3 +44,3 @@ var fs = require('fs'); | ||
var exists = common.existsSync(dest); | ||
var exists = fs.existsSync(dest); | ||
var stats = exists && fs.statSync(dest); | ||
@@ -59,4 +59,4 @@ | ||
sources.forEach(function (src) { | ||
if (!common.existsSync(src)) { | ||
common.error('no such file or directory: ' + src, true); | ||
if (!fs.existsSync(src)) { | ||
common.error('no such file or directory: ' + src, { continue: true }); | ||
return; // skip file | ||
@@ -70,8 +70,8 @@ } | ||
var thisDest = dest; | ||
if (common.existsSync(dest) && fs.statSync(dest).isDirectory()) { | ||
if (fs.existsSync(dest) && fs.statSync(dest).isDirectory()) { | ||
thisDest = path.normalize(dest + '/' + path.basename(src)); | ||
} | ||
if (common.existsSync(thisDest) && options.no_force) { | ||
common.error('dest file already exists: ' + thisDest, true); | ||
if (fs.existsSync(thisDest) && options.no_force) { | ||
common.error('dest file already exists: ' + thisDest, { continue: true }); | ||
return; // skip file | ||
@@ -81,3 +81,3 @@ } | ||
if (path.resolve(src) === path.dirname(path.resolve(thisDest))) { | ||
common.error('cannot move to self: ' + src, true); | ||
common.error('cannot move to self: ' + src, { continue: true }); | ||
return; // skip file | ||
@@ -84,0 +84,0 @@ } |
@@ -37,3 +37,3 @@ var common = require('./common'); | ||
} catch (e) { | ||
common.error('could not remove file (code ' + e.code + '): ' + file, true); | ||
common.error('could not remove file (code ' + e.code + '): ' + file, { continue: true }); | ||
} | ||
@@ -54,3 +54,3 @@ } | ||
result = fs.rmdirSync(dir); | ||
if (common.existsSync(dir)) throw { code: 'EAGAIN' }; | ||
if (fs.existsSync(dir)) throw { code: 'EAGAIN' }; | ||
break; | ||
@@ -70,3 +70,3 @@ } catch (er) { | ||
} catch (e) { | ||
common.error('could not remove directory (code ' + e.code + '): ' + dir, true); | ||
common.error('could not remove directory (code ' + e.code + '): ' + dir, { continue: true }); | ||
} | ||
@@ -121,3 +121,3 @@ | ||
if (!options.force) { | ||
common.error('no such file or directory: ' + file, true); | ||
common.error('no such file or directory: ' + file, { continue: true }); | ||
} | ||
@@ -138,3 +138,3 @@ return; // skip file | ||
} else { | ||
common.error('permission denied: ' + file, true); | ||
common.error('permission denied: ' + file, { continue: true }); | ||
} | ||
@@ -147,3 +147,3 @@ | ||
if (stats.isDirectory() && !options.recursive) { | ||
common.error('path is a directory', true); | ||
common.error('path is a directory', { continue: true }); | ||
return; // skip path | ||
@@ -150,0 +150,0 @@ } |
@@ -57,4 +57,4 @@ var common = require('./common'); | ||
files.forEach(function (file) { | ||
if (!common.existsSync(file) && file !== '-') { | ||
common.error('no such file or directory: ' + file, 2, true); | ||
if (!fs.existsSync(file) && file !== '-') { | ||
common.error('no such file or directory: ' + file, 2, { continue: true }); | ||
return; | ||
@@ -61,0 +61,0 @@ } |
@@ -72,3 +72,3 @@ var common = require('./common'); | ||
files.forEach(function (file) { | ||
if (!common.existsSync(file) && file !== '-') { | ||
if (!fs.existsSync(file) && file !== '-') { | ||
// exit upon any sort of error | ||
@@ -75,0 +75,0 @@ common.error('no such file or directory: ' + file); |
@@ -49,4 +49,4 @@ var common = require('./common'); | ||
files.forEach(function (file) { | ||
if (!common.existsSync(file) && file !== '-') { | ||
common.error('no such file or directory: ' + file, true); | ||
if (!fs.existsSync(file) && file !== '-') { | ||
common.error('no such file or directory: ' + file, { continue: true }); | ||
return; | ||
@@ -53,0 +53,0 @@ } |
@@ -12,3 +12,3 @@ var common = require('./common'); | ||
function writeableDir(dir) { | ||
if (!dir || !common.existsSync(dir)) return false; | ||
if (!dir || !fs.existsSync(dir)) return false; | ||
@@ -15,0 +15,0 @@ if (!fs.statSync(dir).isDirectory()) return false; |
@@ -16,2 +16,3 @@ var common = require('./common'); | ||
wrapOutput: false, | ||
allowGlobbing: false, | ||
}); | ||
@@ -61,3 +62,3 @@ | ||
if (!common.existsSync(path)) return false; | ||
if (!fs.existsSync(path)) return false; | ||
@@ -64,0 +65,0 @@ if (options.exists) return true; |
@@ -25,3 +25,3 @@ var common = require('./common'); | ||
if (!common.existsSync(path.dirname(file))) { | ||
if (!fs.existsSync(path.dirname(file))) { | ||
common.error('no such file or directory: ' + path.dirname(file)); | ||
@@ -34,5 +34,5 @@ } | ||
} catch (e) { | ||
common.error('could not write to file (code ' + e.code + '): ' + file, true); | ||
common.error('could not write to file (code ' + e.code + '): ' + file, { continue: true }); | ||
} | ||
} | ||
module.exports = _to; |
@@ -24,3 +24,3 @@ var common = require('./common'); | ||
if (!common.existsSync(path.dirname(file))) { | ||
if (!fs.existsSync(path.dirname(file))) { | ||
common.error('no such file or directory: ' + path.dirname(file)); | ||
@@ -33,5 +33,5 @@ } | ||
} catch (e) { | ||
common.error('could not append to file (code ' + e.code + '): ' + file, true); | ||
common.error('could not append to file (code ' + e.code + '): ' + file, { continue: true }); | ||
} | ||
} | ||
module.exports = _toEnd; |
@@ -25,3 +25,3 @@ var common = require('./common'); | ||
function checkPath(pathName) { | ||
return common.existsSync(pathName) && !fs.statSync(pathName).isDirectory(); | ||
return fs.existsSync(pathName) && !fs.statSync(pathName).isDirectory(); | ||
} | ||
@@ -28,0 +28,0 @@ |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 9 instances in 1 package
168816
2991
785
53