http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/shelljs/scripts/generate-docs.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/scripts/generate-docs.js b/node_modules/shelljs/scripts/generate-docs.js index 3a31a91..532fed9 100755 --- a/node_modules/shelljs/scripts/generate-docs.js +++ b/node_modules/shelljs/scripts/generate-docs.js @@ -1,5 +1,4 @@ #!/usr/bin/env node -/* globals cat, cd, echo, grep, sed */ require('../global'); echo('Appending docs to README.md'); @@ -16,11 +15,7 @@ docs = docs.replace(/\/\/\@include (.+)/g, function(match, path) { // Remove '//@' docs = docs.replace(/\/\/\@ ?/g, ''); - -// Wipe out the old docs -cat('README.md').replace(/## Command reference(.|\n)*/, '## Command reference').to('README.md'); - -// Append new docs to README -sed('-i', /## Command reference/, '## Command reference\n\n' + docs, 'README.md'); +// Append docs to README +sed('-i', /## Command reference(.|\n)*/, '## Command reference\n\n' + docs, 'README.md'); echo('All done.');
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/shelljs/scripts/run-tests.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/scripts/run-tests.js b/node_modules/shelljs/scripts/run-tests.js index e8e7ff2..f9d31e0 100755 --- a/node_modules/shelljs/scripts/run-tests.js +++ b/node_modules/shelljs/scripts/run-tests.js @@ -1,14 +1,14 @@ #!/usr/bin/env node -/* globals cd, echo, exec, exit, ls, pwd, test */ require('../global'); -var common = require('../src/common'); + +var path = require('path'); var failed = false; // // Lint // -var JSHINT_BIN = 'node_modules/jshint/bin/jshint'; +JSHINT_BIN = './node_modules/jshint/bin/jshint'; cd(__dirname + '/..'); if (!test('-f', JSHINT_BIN)) { @@ -16,12 +16,7 @@ if (!test('-f', JSHINT_BIN)) { exit(1); } -var jsfiles = common.expand([pwd() + '/*.js', - pwd() + '/scripts/*.js', - pwd() + '/src/*.js', - pwd() + '/test/*.js' - ]).join(' '); -if (exec('node ' + pwd() + '/' + JSHINT_BIN + ' ' + jsfiles).code !== 0) { +if (exec(JSHINT_BIN + ' *.js test/*.js').code !== 0) { failed = true; echo('*** JSHINT FAILED! (return code != 0)'); echo(); http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/shelljs/shell.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/shell.js b/node_modules/shelljs/shell.js index 93aff70..bdeb559 100644 --- a/node_modules/shelljs/shell.js +++ b/node_modules/shelljs/shell.js @@ -107,13 +107,6 @@ exports.exec = common.wrap('exec', _exec, {notUnix:true}); var _chmod = require('./src/chmod'); exports.chmod = common.wrap('chmod', _chmod); -//@include ./src/touch -var _touch = require('./src/touch'); -exports.touch = common.wrap('touch', _touch); - -//@include ./src/set -var _set = require('./src/set'); -exports.set = common.wrap('set', _set); //@ @@ -158,27 +151,9 @@ exports.config = common.config; //@ //@ ```javascript //@ require('shelljs/global'); -//@ config.fatal = true; // or set('-e'); +//@ config.fatal = true; //@ cp('this_file_does_not_exist', '/dev/null'); // dies here //@ /* more commands... */ //@ ``` //@ -//@ If `true` the script will die on errors. Default is `false`. This is -//@ analogous to Bash's `set -e` - -//@ -//@ ### config.verbose -//@ Example: -//@ -//@ ```javascript -//@ config.verbose = true; // or set('-v'); -//@ cd('dir/'); -//@ ls('subdir/'); -//@ ``` -//@ -//@ Will print each command as follows: -//@ -//@ ``` -//@ cd dir/ -//@ ls subdir/ -//@ ``` +//@ If `true` the script will die on errors. Default is `false`. http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/shelljs/src/cat.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/src/cat.js b/node_modules/shelljs/src/cat.js index 5840b4e..f6f4d25 100644 --- a/node_modules/shelljs/src/cat.js +++ b/node_modules/shelljs/src/cat.js @@ -32,9 +32,12 @@ function _cat(options, files) { if (!fs.existsSync(file)) common.error('no such file or directory: ' + file); - cat += fs.readFileSync(file, 'utf8'); + cat += fs.readFileSync(file, 'utf8') + '\n'; }); + if (cat[cat.length-1] === '\n') + cat = cat.substring(0, cat.length-1); + return common.ShellString(cat); } module.exports = _cat; http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/shelljs/src/cd.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/src/cd.js b/node_modules/shelljs/src/cd.js index b7b9931..230f432 100644 --- a/node_modules/shelljs/src/cd.js +++ b/node_modules/shelljs/src/cd.js @@ -2,19 +2,11 @@ var fs = require('fs'); var common = require('./common'); //@ -//@ ### cd([dir]) -//@ Changes to directory `dir` for the duration of the script. Changes to home -//@ directory if no argument is supplied. +//@ ### cd('dir') +//@ Changes to directory `dir` for the duration of the script function _cd(options, dir) { if (!dir) - dir = common.getUserHome(); - - if (dir === '-') { - if (!common.state.previousDir) - common.error('could not find previous directory'); - else - dir = common.state.previousDir; - } + common.error('directory not specified'); if (!fs.existsSync(dir)) common.error('no such file or directory: ' + dir); @@ -22,7 +14,6 @@ function _cd(options, dir) { if (!fs.statSync(dir).isDirectory()) common.error('not a directory: ' + dir); - common.state.previousDir = process.cwd(); process.chdir(dir); } module.exports = _cd; http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/shelljs/src/chmod.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/src/chmod.js b/node_modules/shelljs/src/chmod.js index 6c6de10..f288893 100644 --- a/node_modules/shelljs/src/chmod.js +++ b/node_modules/shelljs/src/chmod.js @@ -114,9 +114,7 @@ function _chmod(options, mode, filePattern) { return; } - var stat = fs.statSync(file); - var isDir = stat.isDirectory(); - var perms = stat.mode; + var perms = fs.statSync(file).mode; var type = perms & PERMS.TYPE_MASK; var newPerms = perms; @@ -137,15 +135,11 @@ function _chmod(options, mode, filePattern) { var changeGroup = applyTo.indexOf('g') != -1 || applyTo === 'a' || applyTo === ''; var changeOther = applyTo.indexOf('o') != -1 || applyTo === 'a' || applyTo === ''; - var changeRead = change.indexOf('r') != -1; - var changeWrite = change.indexOf('w') != -1; - var changeExec = change.indexOf('x') != -1; - var changeExecDir = change.indexOf('X') != -1; - var changeSticky = change.indexOf('t') != -1; - var changeSetuid = change.indexOf('s') != -1; - - if (changeExecDir && isDir) - changeExec = true; + var changeRead = change.indexOf('r') != -1; + var changeWrite = change.indexOf('w') != -1; + var changeExec = change.indexOf('x') != -1; + var changeSticky = change.indexOf('t') != -1; + var changeSetuid = change.indexOf('s') != -1; var mask = 0; if (changeOwner) { @@ -183,15 +177,14 @@ function _chmod(options, mode, filePattern) { } if (options.verbose) { - console.log(file + ' -> ' + newPerms.toString(8)); + log(file + ' -> ' + newPerms.toString(8)); } if (perms != newPerms) { if (!options.verbose && options.changes) { - console.log(file + ' -> ' + newPerms.toString(8)); + log(file + ' -> ' + newPerms.toString(8)); } fs.chmodSync(file, newPerms); - perms = newPerms; // for the next round of changes! } } else { http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/shelljs/src/common.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/src/common.js b/node_modules/shelljs/src/common.js index 33198bd..d8c2312 100644 --- a/node_modules/shelljs/src/common.js +++ b/node_modules/shelljs/src/common.js @@ -5,15 +5,13 @@ var _ls = require('./ls'); // Module globals var config = { silent: false, - fatal: false, - verbose: false, + fatal: false }; exports.config = config; var state = { error: null, currentCmd: 'shell.js', - previousDir: null, tempDir: null }; exports.state = state; @@ -23,7 +21,7 @@ exports.platform = platform; function log() { if (!config.silent) - console.error.apply(console, arguments); + console.log.apply(this, arguments); } exports.log = log; @@ -31,14 +29,10 @@ exports.log = log; function error(msg, _continue) { if (state.error === null) state.error = ''; - var log_entry = state.currentCmd + ': ' + msg; - if (state.error === '') - state.error = log_entry; - else - state.error += '\n' + log_entry; + state.error += state.currentCmd + ': ' + msg + '\n'; if (msg.length > 0) - log(log_entry); + log(state.error); if (config.fatal) process.exit(1); @@ -55,69 +49,38 @@ function ShellString(str) { } exports.ShellString = ShellString; -// Return the home directory in a platform-agnostic way, with consideration for -// older versions of node -function getUserHome() { - var result; - if (os.homedir) - result = os.homedir(); // node 3+ - else - result = process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME']; - return result; -} -exports.getUserHome = getUserHome; - -// Returns {'alice': true, 'bob': false} when passed a string and dictionary as follows: +// Returns {'alice': true, 'bob': false} when passed a dictionary, e.g.: // parseOptions('-a', {'a':'alice', 'b':'bob'}); -// Returns {'reference': 'string-value', 'bob': false} when passed two dictionaries of the form: -// parseOptions({'-r': 'string-value'}, {'r':'reference', 'b':'bob'}); -function parseOptions(opt, map) { +function parseOptions(str, map) { if (!map) error('parseOptions() internal error: no map given'); // All options are false by default var options = {}; - for (var letter in map) { - if (map[letter][0] !== '!') - options[map[letter]] = false; - } + for (var letter in map) + options[map[letter]] = false; - if (!opt) + if (!str) return options; // defaults - var optionName; - if (typeof opt === 'string') { - if (opt[0] !== '-') - return options; + if (typeof str !== 'string') + error('parseOptions() internal error: wrong str'); - // e.g. chars = ['R', 'f'] - var chars = opt.slice(1).split(''); + // e.g. match[1] = 'Rf' for str = '-Rf' + var match = str.match(/^\-(.+)/); + if (!match) + return options; + + // e.g. chars = ['R', 'f'] + var chars = match[1].split(''); + + chars.forEach(function(c) { + if (c in map) + options[map[c]] = true; + else + error('option not recognized: '+c); + }); - chars.forEach(function(c) { - if (c in map) { - optionName = map[c]; - if (optionName[0] === '!') - options[optionName.slice(1, optionName.length-1)] = false; - else - options[optionName] = true; - } else { - error('option not recognized: '+c); - } - }); - } else if (typeof opt === 'object') { - for (var key in opt) { - // key is a string of the form '-r', '-d', etc. - var c = key[1]; - if (c in map) { - optionName = map[c]; - options[optionName] = opt[key]; // assign the given value - } else { - error('option not recognized: '+c); - } - } - } else { - error('options must be strings or key-value pairs'); - } return options; } exports.parseOptions = parseOptions; @@ -136,7 +99,7 @@ function expand(list) { var rest = match[2]; var restRegex = rest.replace(/\*\*/g, ".*").replace(/\*/g, "[^\\/]*"); restRegex = new RegExp(restRegex); - + _ls('-R', root).filter(function (e) { return restRegex.test(e); }).forEach(function(file) { @@ -215,28 +178,11 @@ function wrap(cmd, fn, options) { try { var args = [].slice.call(arguments, 0); - if (config.verbose) { - args.unshift(cmd); - console.log.apply(console, args); - args.shift(); - } - if (options && options.notUnix) { retValue = fn.apply(this, args); } else { - if (typeof args[0] === 'object' && args[0].constructor.name === 'Object') { - args = args; // object count as options - } else if (args.length === 0 || typeof args[0] !== 'string' || args[0].length <= 1 || args[0][0] !== '-') { + if (args.length === 0 || typeof args[0] !== 'string' || args[0][0] !== '-') args.unshift(''); // only add dummy option if '-option' not already present - } - // Expand the '~' if appropriate - var homeDir = getUserHome(); - args = args.map(function(arg) { - if (typeof arg === 'string' && arg.slice(0, 2) === '~/' || arg === '~') - return arg.replace(/^~/, homeDir); - else - return arg; - }); retValue = fn.apply(this, args); } } catch (e) { http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/shelljs/src/cp.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/src/cp.js b/node_modules/shelljs/src/cp.js index 54404ef..ef19f96 100644 --- a/node_modules/shelljs/src/cp.js +++ b/node_modules/shelljs/src/cp.js @@ -76,7 +76,7 @@ function cpdirSyncRecursive(sourceDir, destDir, opts) { fs.symlinkSync(symlinkFull, destFile, os.platform() === "win32" ? "junction" : null); } else { /* At this point, we've hit a file actually worth copying... so copy it on over. */ - if (fs.existsSync(destFile) && opts.no_force) { + if (fs.existsSync(destFile) && !opts.force) { common.log('skipping existing file: ' + files[i]); } else { copyFileSync(srcFile, destFile); @@ -88,12 +88,11 @@ function cpdirSyncRecursive(sourceDir, destDir, opts) { //@ -//@ ### cp([options,] source [, source ...], dest) -//@ ### cp([options,] source_array, dest) +//@ ### cp([options ,] source [,source ...], dest) +//@ ### cp([options ,] source_array, dest) //@ Available options: //@ -//@ + `-f`: force (default behavior) -//@ + `-n`: no-clobber +//@ + `-f`: force //@ + `-r, -R`: recursive //@ //@ Examples: @@ -107,8 +106,7 @@ function cpdirSyncRecursive(sourceDir, destDir, opts) { //@ Copies files. The wildcard `*` is accepted. function _cp(options, sources, dest) { options = common.parseOptions(options, { - 'f': '!no_force', - 'n': 'no_force', + 'f': 'force', 'R': 'recursive', 'r': 'recursive' }); @@ -135,19 +133,15 @@ function _cp(options, sources, dest) { common.error('dest is not a directory (too many sources)'); // Dest is an existing file, but no -f given - if (exists && stats.isFile() && options.no_force) + if (exists && stats.isFile() && !options.force) common.error('dest file already exists: ' + dest); if (options.recursive) { // Recursive allows the shortcut syntax "sourcedir/" for "sourcedir/*" // (see Github issue #15) sources.forEach(function(src, i) { - if (src[src.length - 1] === '/') { + if (src[src.length - 1] === '/') sources[i] += '*'; - // If src is a directory and dest doesn't exist, 'cp -r src dest' should copy src/* into dest - } else if (fs.statSync(src).isDirectory() && !exists) { - sources[i] += '/*'; - } }); // Create dest @@ -186,7 +180,7 @@ function _cp(options, sources, dest) { } } - cpdirSyncRecursive(src, newDest, {no_force: options.no_force}); + cpdirSyncRecursive(src, newDest, {force: options.force}); } return; // done with dir } @@ -199,7 +193,7 @@ function _cp(options, sources, dest) { if (fs.existsSync(dest) && fs.statSync(dest).isDirectory()) thisDest = path.normalize(dest + '/' + path.basename(src)); - if (fs.existsSync(thisDest) && options.no_force) { + if (fs.existsSync(thisDest) && !options.force) { common.error('dest file already exists: ' + thisDest, true); return; // skip file } http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/shelljs/src/echo.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/src/echo.js b/node_modules/shelljs/src/echo.js index b574adc..760ea84 100644 --- a/node_modules/shelljs/src/echo.js +++ b/node_modules/shelljs/src/echo.js @@ -1,7 +1,7 @@ var common = require('./common'); //@ -//@ ### echo(string [, string ...]) +//@ ### echo(string [,string ...]) //@ //@ Examples: //@ @@ -14,7 +14,7 @@ var common = require('./common'); //@ like `.to()`. function _echo() { var messages = [].slice.call(arguments, 0); - console.log.apply(console, messages); + console.log.apply(this, messages); return common.ShellString(messages.join(' ')); } module.exports = _echo; http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/shelljs/src/error.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/src/error.js b/node_modules/shelljs/src/error.js index 112563d..cca3efb 100644 --- a/node_modules/shelljs/src/error.js +++ b/node_modules/shelljs/src/error.js @@ -6,5 +6,5 @@ var common = require('./common'); //@ otherwise returns string explaining the error function error() { return common.state.error; -} +}; module.exports = error; http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/shelljs/src/exec.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/src/exec.js b/node_modules/shelljs/src/exec.js index 4174adb..d259a9f 100644 --- a/node_modules/shelljs/src/exec.js +++ b/node_modules/shelljs/src/exec.js @@ -5,8 +5,6 @@ var path = require('path'); var fs = require('fs'); var child = require('child_process'); -var DEFAULT_MAXBUFFER_SIZE = 20*1024*1024; - // Hack to run child_process.exec() synchronously (sync avoids callback hell) // Uses a custom wait loop that checks for a flag file, created when the child process is done. // (Can't do a wait loop that checks for internal Node variables/messages as @@ -15,42 +13,27 @@ var DEFAULT_MAXBUFFER_SIZE = 20*1024*1024; function execSync(cmd, opts) { var tempDir = _tempDir(); var stdoutFile = path.resolve(tempDir+'/'+common.randomFileName()), - stderrFile = path.resolve(tempDir+'/'+common.randomFileName()), codeFile = path.resolve(tempDir+'/'+common.randomFileName()), scriptFile = path.resolve(tempDir+'/'+common.randomFileName()), sleepFile = path.resolve(tempDir+'/'+common.randomFileName()); - opts = common.extend({ - silent: common.config.silent, - cwd: _pwd(), - env: process.env, - maxBuffer: DEFAULT_MAXBUFFER_SIZE + var options = common.extend({ + silent: common.config.silent }, opts); - var previousStdoutContent = '', - previousStderrContent = ''; - // Echoes stdout and stderr changes from running process, if not silent - function updateStream(streamFile) { - if (opts.silent || !fs.existsSync(streamFile)) + var previousStdoutContent = ''; + // Echoes stdout changes from running process, if not silent + function updateStdout() { + if (options.silent || !fs.existsSync(stdoutFile)) return; - var previousStreamContent, - proc_stream; - if (streamFile === stdoutFile) { - previousStreamContent = previousStdoutContent; - proc_stream = process.stdout; - } else { // assume stderr - previousStreamContent = previousStderrContent; - proc_stream = process.stderr; - } - - var streamContent = fs.readFileSync(streamFile, 'utf8'); + var stdoutContent = fs.readFileSync(stdoutFile, 'utf8'); // No changes since last time? - if (streamContent.length <= previousStreamContent.length) + if (stdoutContent.length <= previousStdoutContent.length) return; - proc_stream.write(streamContent.substr(previousStreamContent.length)); - previousStreamContent = streamContent; + process.stdout.write(stdoutContent.substr(previousStdoutContent.length)); + previousStdoutContent = stdoutContent; } function escape(str) { @@ -59,64 +42,64 @@ function execSync(cmd, opts) { 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); var execCommand = '"'+process.execPath+'" '+scriptFile; - var script; + var execOptions = { + env: process.env, + cwd: _pwd(), + maxBuffer: 20*1024*1024 + }; if (typeof child.execSync === 'function') { - script = [ + var script = [ "var child = require('child_process')", " , fs = require('fs');", - "var childProcess = child.exec('"+escape(cmd)+"', {env: process.env, maxBuffer: "+opts.maxBuffer+"}, function(err) {", + "var childProcess = child.exec('"+escape(cmd)+"', {env: process.env, maxBuffer: 20*1024*1024}, function(err) {", " fs.writeFileSync('"+escape(codeFile)+"', err ? err.code.toString() : '0');", "});", "var stdoutStream = fs.createWriteStream('"+escape(stdoutFile)+"');", - "var stderrStream = fs.createWriteStream('"+escape(stderrFile)+"');", "childProcess.stdout.pipe(stdoutStream, {end: false});", - "childProcess.stderr.pipe(stderrStream, {end: false});", + "childProcess.stderr.pipe(stdoutStream, {end: false});", "childProcess.stdout.pipe(process.stdout);", "childProcess.stderr.pipe(process.stderr);", "var stdoutEnded = false, stderrEnded = false;", - "function tryClosingStdout(){ if(stdoutEnded){ stdoutStream.end(); } }", - "function tryClosingStderr(){ if(stderrEnded){ stderrStream.end(); } }", - "childProcess.stdout.on('end', function(){ stdoutEnded = true; tryClosingStdout(); });", - "childProcess.stderr.on('end', function(){ stderrEnded = true; tryClosingStderr(); });" + "function tryClosing(){ if(stdoutEnded && stderrEnded){ stdoutStream.end(); } }", + "childProcess.stdout.on('end', function(){ stdoutEnded = true; tryClosing(); });", + "childProcess.stderr.on('end', function(){ stderrEnded = true; tryClosing(); });" ].join('\n'); fs.writeFileSync(scriptFile, script); - if (opts.silent) { - opts.stdio = 'ignore'; + if (options.silent) { + execOptions.stdio = 'ignore'; } else { - opts.stdio = [0, 1, 2]; + execOptions.stdio = [0, 1, 2]; } // Welcome to the future - child.execSync(execCommand, opts); + child.execSync(execCommand, execOptions); } else { - cmd += ' > '+stdoutFile+' 2> '+stderrFile; // works on both win/unix + cmd += ' > '+stdoutFile+' 2>&1'; // works on both win/unix - script = [ + var script = [ "var child = require('child_process')", " , fs = require('fs');", - "var childProcess = child.exec('"+escape(cmd)+"', {env: process.env, maxBuffer: "+opts.maxBuffer+"}, function(err) {", + "var childProcess = child.exec('"+escape(cmd)+"', {env: process.env, maxBuffer: 20*1024*1024}, function(err) {", " fs.writeFileSync('"+escape(codeFile)+"', err ? err.code.toString() : '0');", "});" ].join('\n'); fs.writeFileSync(scriptFile, script); - child.exec(execCommand, opts); + child.exec(execCommand, execOptions); // The wait loop // sleepFile is used as a dummy I/O op to mitigate unnecessary CPU usage // (tried many I/O sync ops, writeFileSync() seems to be only one that is effective in reducing // CPU usage, though apparently not so much on Windows) - 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'); } + while (!fs.existsSync(codeFile)) { updateStdout(); fs.writeFileSync(sleepFile, 'a'); } + while (!fs.existsSync(stdoutFile)) { updateStdout(); fs.writeFileSync(sleepFile, 'a'); } } // At this point codeFile exists, but it's not necessarily flushed yet. @@ -127,12 +110,10 @@ function execSync(cmd, opts) { } var stdout = fs.readFileSync(stdoutFile, 'utf8'); - var stderr = fs.readFileSync(stderrFile, 'utf8'); // No biggie if we can't erase the files now -- they're in a temp dir anyway try { common.unlinkSync(scriptFile); } catch(e) {} try { common.unlinkSync(stdoutFile); } catch(e) {} - try { common.unlinkSync(stderrFile); } catch(e) {} try { common.unlinkSync(codeFile); } catch(e) {} try { common.unlinkSync(sleepFile); } catch(e) {} @@ -143,40 +124,34 @@ function execSync(cmd, opts) { // True if successful, false if not var obj = { code: code, - output: stdout, // deprecated - stdout: stdout, - stderr: stderr + output: stdout }; return obj; } // execSync() // Wrapper around exec() to enable echoing output to console in real time function execAsync(cmd, opts, callback) { - var stdout = ''; - var stderr = ''; + var output = ''; - opts = common.extend({ - silent: common.config.silent, - cwd: _pwd(), - env: process.env, - maxBuffer: DEFAULT_MAXBUFFER_SIZE + var options = common.extend({ + silent: common.config.silent }, opts); - var c = child.exec(cmd, opts, function(err) { + var c = child.exec(cmd, {env: process.env, maxBuffer: 20*1024*1024}, function(err) { if (callback) - callback(err ? err.code : 0, stdout, stderr); + callback(err ? err.code : 0, output); }); c.stdout.on('data', function(data) { - stdout += data; - if (!opts.silent) + output += data; + if (!options.silent) process.stdout.write(data); }); c.stderr.on('data', function(data) { - stderr += data; - if (!opts.silent) - process.stderr.write(data); + output += data; + if (!options.silent) + process.stdout.write(data); }); return c; @@ -186,33 +161,29 @@ function execAsync(cmd, opts, callback) { //@ ### exec(command [, options] [, callback]) //@ Available options (all `false` by default): //@ -//@ + `async`: Asynchronous execution. If a callback is provided, it will be set to -//@ `true`, regardless of the passed value. +//@ + `async`: Asynchronous execution. Defaults to true if a callback is provided. //@ + `silent`: Do not echo program output to console. -//@ + and any option available to NodeJS's -//@ [child_process.exec()](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback) //@ //@ Examples: //@ //@ ```javascript -//@ var version = exec('node --version', {silent:true}).stdout; +//@ var version = exec('node --version', {silent:true}).output; //@ //@ var child = exec('some_long_running_process', {async:true}); //@ child.stdout.on('data', function(data) { //@ /* ... do something with data ... */ //@ }); //@ -//@ exec('some_long_running_process', function(code, stdout, stderr) { +//@ exec('some_long_running_process', function(code, output) { //@ console.log('Exit code:', code); -//@ console.log('Program output:', stdout); -//@ console.log('Program stderr:', stderr); +//@ console.log('Program output:', output); //@ }); //@ ``` //@ -//@ Executes the given `command` _synchronously_, unless otherwise specified. When in synchronous -//@ mode returns the object `{ code:..., stdout:... , stderr:... }`, containing the program's -//@ `stdout`, `stderr`, and its exit `code`. Otherwise returns the child process object, -//@ and the `callback` gets the arguments `(code, stdout, stderr)`. +//@ Executes the given `command` _synchronously_, unless otherwise specified. +//@ When in synchronous mode returns the object `{ code:..., output:... }`, containing the program's +//@ `output` (stdout + stderr) and its exit `code`. Otherwise returns the child process object, and +//@ the `callback` gets the arguments `(code, output)`. //@ //@ **Note:** For long-lived processes, it's best to run `exec()` asynchronously as //@ the current synchronous implementation uses a lot of CPU. This should be getting @@ -237,13 +208,9 @@ function _exec(command, options, callback) { async: false }, options); - try { - if (options.async) - return execAsync(command, options, callback); - else - return execSync(command, options); - } catch (e) { - common.error('internal error'); - } + if (options.async) + return execAsync(command, options, callback); + else + return execSync(command, options); } module.exports = _exec; http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/shelljs/src/find.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/src/find.js b/node_modules/shelljs/src/find.js index c96fb2f..d9eeec2 100644 --- a/node_modules/shelljs/src/find.js +++ b/node_modules/shelljs/src/find.js @@ -3,7 +3,7 @@ var common = require('./common'); var _ls = require('./ls'); //@ -//@ ### find(path [, path ...]) +//@ ### find(path [,path ...]) //@ ### find(path_array) //@ Examples: //@ http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/shelljs/src/grep.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/src/grep.js b/node_modules/shelljs/src/grep.js index 78008ce..00c7d6a 100644 --- a/node_modules/shelljs/src/grep.js +++ b/node_modules/shelljs/src/grep.js @@ -2,8 +2,8 @@ var common = require('./common'); var fs = require('fs'); //@ -//@ ### grep([options,] regex_filter, file [, file ...]) -//@ ### grep([options,] regex_filter, file_array) +//@ ### grep([options ,] regex_filter, file [, file ...]) +//@ ### grep([options ,] regex_filter, file_array) //@ Available options: //@ //@ + `-v`: Inverse the sense of the regex and print the lines not matching the criteria. http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/shelljs/src/ln.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/src/ln.js b/node_modules/shelljs/src/ln.js index 878fda1..a7b9701 100644 --- a/node_modules/shelljs/src/ln.js +++ b/node_modules/shelljs/src/ln.js @@ -1,13 +1,15 @@ var fs = require('fs'); var path = require('path'); var common = require('./common'); +var os = require('os'); //@ -//@ ### ln([options,] source, dest) +//@ ### ln(options, source, dest) +//@ ### ln(source, dest) //@ Available options: //@ -//@ + `-s`: symlink -//@ + `-f`: force +//@ + `s`: symlink +//@ + `f`: force //@ //@ Examples: //@ @@ -27,11 +29,13 @@ function _ln(options, source, dest) { common.error('Missing <source> and/or <dest>'); } - source = String(source); - var sourcePath = path.normalize(source).replace(RegExp(path.sep + '$'), ''); - var isAbsolute = (path.resolve(source) === sourcePath); + source = path.resolve(process.cwd(), String(source)); dest = path.resolve(process.cwd(), String(dest)); + if (!fs.existsSync(source)) { + common.error('Source file does not exist', true); + } + if (fs.existsSync(dest)) { if (!options.force) { common.error('Destination file exists', true); @@ -41,29 +45,9 @@ function _ln(options, source, dest) { } if (options.symlink) { - var isWindows = common.platform === 'win'; - var linkType = isWindows ? 'file' : null; - var resolvedSourcePath = isAbsolute ? sourcePath : path.resolve(process.cwd(), path.dirname(dest), source); - if (!fs.existsSync(resolvedSourcePath)) { - common.error('Source file does not exist', true); - } else if (isWindows && fs.statSync(resolvedSourcePath).isDirectory()) { - linkType = 'junction'; - } - - try { - fs.symlinkSync(linkType === 'junction' ? resolvedSourcePath: source, dest, linkType); - } catch (err) { - common.error(err.message); - } + fs.symlinkSync(source, dest, os.platform() === "win32" ? "junction" : null); } else { - if (!fs.existsSync(source)) { - common.error('Source file does not exist', true); - } - try { - fs.linkSync(source, dest); - } catch (err) { - common.error(err.message); - } + fs.linkSync(source, dest, os.platform() === "win32" ? "junction" : null); } } module.exports = _ln; http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/shelljs/src/ls.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/src/ls.js b/node_modules/shelljs/src/ls.js index 6a54b3a..3345db4 100644 --- a/node_modules/shelljs/src/ls.js +++ b/node_modules/shelljs/src/ls.js @@ -5,17 +5,12 @@ var _cd = require('./cd'); var _pwd = require('./pwd'); //@ -//@ ### ls([options,] [path, ...]) -//@ ### ls([options,] path_array) +//@ ### ls([options ,] path [,path ...]) +//@ ### ls([options ,] path_array) //@ Available options: //@ //@ + `-R`: recursive //@ + `-A`: all files (include files beginning with `.`, except for `.` and `..`) -//@ + `-d`: list directories themselves, not their contents -//@ + `-l`: list objects representing each file, each with fields containing `ls -//@ -l` output fields. See -//@ [fs.Stats](https://nodejs.org/api/fs.html#fs_class_fs_stats) -//@ for more info //@ //@ Examples: //@ @@ -23,7 +18,6 @@ var _pwd = require('./pwd'); //@ ls('projs/*.js'); //@ ls('-R', '/users/me', '/tmp'); //@ ls('-R', ['/users/me', '/tmp']); // same as above -//@ ls('-l', 'file.txt'); // { name: 'file.txt', mode: 33188, nlink: 1, ...} //@ ``` //@ //@ Returns array of files in the given path, or in current directory if no path provided. @@ -31,9 +25,7 @@ function _ls(options, paths) { options = common.parseOptions(options, { 'R': 'recursive', 'A': 'all', - 'a': 'all_deprecated', - 'd': 'directory', - 'l': 'long' + 'a': 'all_deprecated' }); if (options.all_deprecated) { @@ -56,49 +48,33 @@ function _ls(options, paths) { // Conditionally pushes file to list - returns true if pushed, false otherwise // (e.g. prevents hidden files to be included unless explicitly told so) function pushFile(file, query) { - var name = file.name || file; // hidden file? - if (path.basename(name)[0] === '.') { + if (path.basename(file)[0] === '.') { // not explicitly asking for hidden files? if (!options.all && !(path.basename(query)[0] === '.' && path.basename(query).length > 1)) return false; } if (common.platform === 'win') - name = name.replace(/\\/g, '/'); + file = file.replace(/\\/g, '/'); - if (file.name) { - file.name = name; - } else { - file = name; - } list.push(file); return true; } paths.forEach(function(p) { if (fs.existsSync(p)) { - var stats = ls_stat(p); + var stats = fs.statSync(p); // Simple file? if (stats.isFile()) { - if (options.long) { - pushFile(stats, p); - } else { - pushFile(p, p); - } + pushFile(p, p); return; // continue } // Simple dir? - if (options.directory) { - pushFile(p, p); - return; - } else if (stats.isDirectory()) { + if (stats.isDirectory()) { // Iterate over p contents fs.readdirSync(p).forEach(function(file) { - var orig_file = file; - if (options.long) - file = ls_stat(path.join(p, file)); if (!pushFile(file, p)) return; @@ -106,8 +82,8 @@ function _ls(options, paths) { if (options.recursive) { var oldDir = _pwd(); _cd('', p); - if (fs.statSync(orig_file).isDirectory()) - list = list.concat(_ls('-R'+(options.all?'A':''), orig_file+'/*')); + if (fs.statSync(file).isDirectory()) + list = list.concat(_ls('-R'+(options.all?'A':''), file+'/*')); _cd('', oldDir); } }); @@ -128,13 +104,7 @@ function _ls(options, paths) { // Iterate over directory contents fs.readdirSync(dirname).forEach(function(file) { if (file.match(new RegExp(regexp))) { - var file_path = path.join(dirname, file); - file_path = options.long ? ls_stat(file_path) : file_path; - if (file_path.name) - file_path.name = path.normalize(file_path.name); - else - file_path = path.normalize(file_path); - if (!pushFile(file_path, basename)) + if (!pushFile(path.normalize(dirname+'/'+file), basename)) return; // Recursive? @@ -154,15 +124,3 @@ function _ls(options, paths) { return list; } module.exports = _ls; - - -function ls_stat(path) { - var stats = fs.statSync(path); - // Note: this object will contain more information than .toString() returns - stats.name = path; - stats.toString = function() { - // Return a string resembling unix's `ls -l` format - return [this.mode, this.nlink, this.uid, this.gid, this.size, this.mtime, this.name].join(' '); - }; - return stats; -} http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/shelljs/src/mkdir.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/src/mkdir.js b/node_modules/shelljs/src/mkdir.js index 8b4fd99..5a7088f 100644 --- a/node_modules/shelljs/src/mkdir.js +++ b/node_modules/shelljs/src/mkdir.js @@ -20,11 +20,11 @@ function mkdirSyncRecursive(dir) { } //@ -//@ ### mkdir([options,] dir [, dir ...]) -//@ ### mkdir([options,] dir_array) +//@ ### mkdir([options ,] dir [, dir ...]) +//@ ### mkdir([options ,] dir_array) //@ Available options: //@ -//@ + `-p`: full path (will create intermediate dirs if necessary) +//@ + `p`: full path (will create intermediate dirs if necessary) //@ //@ Examples: //@ http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/shelljs/src/mv.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/src/mv.js b/node_modules/shelljs/src/mv.js index 69cc03f..11f9607 100644 --- a/node_modules/shelljs/src/mv.js +++ b/node_modules/shelljs/src/mv.js @@ -3,17 +3,16 @@ var path = require('path'); var common = require('./common'); //@ -//@ ### mv([options ,] source [, source ...], dest') -//@ ### mv([options ,] source_array, dest') +//@ ### mv(source [, source ...], dest') +//@ ### mv(source_array, dest') //@ Available options: //@ -//@ + `-f`: force (default behavior) -//@ + `-n`: no-clobber +//@ + `f`: force //@ //@ Examples: //@ //@ ```javascript -//@ mv('-n', 'file', 'dir/'); +//@ mv('-f', 'file', 'dir/'); //@ mv('file1', 'file2', 'dir/'); //@ mv(['file1', 'file2'], 'dir/'); // same as above //@ ``` @@ -21,8 +20,7 @@ var common = require('./common'); //@ Moves files. The wildcard `*` is accepted. function _mv(options, sources, dest) { options = common.parseOptions(options, { - 'f': '!no_force', - 'n': 'no_force' + 'f': 'force' }); // Get sources, dest @@ -49,7 +47,7 @@ function _mv(options, sources, dest) { common.error('dest is not a directory (too many sources)'); // Dest is an existing file, but no -f given - if (exists && stats.isFile() && options.no_force) + if (exists && stats.isFile() && !options.force) common.error('dest file already exists: ' + dest); sources.forEach(function(src) { @@ -66,7 +64,7 @@ function _mv(options, sources, dest) { if (fs.existsSync(dest) && fs.statSync(dest).isDirectory()) thisDest = path.normalize(dest + '/' + path.basename(src)); - if (fs.existsSync(thisDest) && options.no_force) { + if (fs.existsSync(thisDest) && !options.force) { common.error('dest file already exists: ' + thisDest, true); return; // skip file } http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/shelljs/src/pwd.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/src/pwd.js b/node_modules/shelljs/src/pwd.js index 26cefe0..41727bb 100644 --- a/node_modules/shelljs/src/pwd.js +++ b/node_modules/shelljs/src/pwd.js @@ -4,7 +4,7 @@ var common = require('./common'); //@ //@ ### pwd() //@ Returns the current directory. -function _pwd() { +function _pwd(options) { var pwd = path.resolve(process.cwd()); return common.ShellString(pwd); } http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/shelljs/src/rm.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/src/rm.js b/node_modules/shelljs/src/rm.js index cf2e95b..bd608cb 100644 --- a/node_modules/shelljs/src/rm.js +++ b/node_modules/shelljs/src/rm.js @@ -53,7 +53,7 @@ function rmdirSyncRecursive(dir, force) { while (true) { try { result = fs.rmdirSync(dir); - if (fs.existsSync(dir)) throw { code: "EAGAIN" }; + if (fs.existsSync(dir)) throw { code: "EAGAIN" } break; } catch(er) { // In addition to error codes, also check if the directory still exists and loop again if true @@ -89,8 +89,8 @@ function isWriteable(file) { } //@ -//@ ### rm([options,] file [, file ...]) -//@ ### rm([options,] file_array) +//@ ### rm([options ,] file [, file ...]) +//@ ### rm([options ,] file_array) //@ Available options: //@ //@ + `-f`: force http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/shelljs/src/sed.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/src/sed.js b/node_modules/shelljs/src/sed.js index baa385b..65f7cb4 100644 --- a/node_modules/shelljs/src/sed.js +++ b/node_modules/shelljs/src/sed.js @@ -2,8 +2,7 @@ var common = require('./common'); var fs = require('fs'); //@ -//@ ### sed([options,] search_regex, replacement, file [, file ...]) -//@ ### sed([options,] search_regex, replacement, file_array) +//@ ### sed([options ,] search_regex, replacement, file) //@ Available options: //@ //@ + `-i`: Replace contents of 'file' in-place. _Note that no backups will be created!_ @@ -15,9 +14,9 @@ var fs = require('fs'); //@ sed(/.*DELETE_THIS_LINE.*\n/, '', 'source.js'); //@ ``` //@ -//@ Reads an input string from `files` and performs a JavaScript `replace()` on the input +//@ Reads an input string from `file` and performs a JavaScript `replace()` on the input //@ using the given search regex and replacement string or function. Returns the new string after replacement. -function _sed(options, regex, replacement, files) { +function _sed(options, regex, replacement, file) { options = common.parseOptions(options, { 'i': 'inplace' }); @@ -29,36 +28,16 @@ function _sed(options, regex, replacement, files) { else common.error('invalid replacement string'); - // Convert all search strings to RegExp - if (typeof regex === 'string') - regex = RegExp(regex); + if (!file) + common.error('no file given'); - if (!files) - common.error('no files given'); + if (!fs.existsSync(file)) + common.error('no such file or directory: ' + file); - if (typeof files === 'string') - files = [].slice.call(arguments, 3); - // if it's array leave it as it is + var result = fs.readFileSync(file, 'utf8').replace(regex, replacement); + if (options.inplace) + fs.writeFileSync(file, result, 'utf8'); - files = common.expand(files); - - var sed = []; - files.forEach(function(file) { - if (!fs.existsSync(file)) { - common.error('no such file or directory: ' + file, true); - return; - } - - var result = fs.readFileSync(file, 'utf8').split('\n').map(function (line) { - return line.replace(regex, replacement); - }).join('\n'); - - sed.push(result); - - if (options.inplace) - fs.writeFileSync(file, result, 'utf8'); - }); - - return common.ShellString(sed.join('\n')); + return common.ShellString(result); } module.exports = _sed; http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/shelljs/src/set.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/src/set.js b/node_modules/shelljs/src/set.js deleted file mode 100644 index 19e26d9..0000000 --- a/node_modules/shelljs/src/set.js +++ /dev/null @@ -1,49 +0,0 @@ -var common = require('./common'); - -//@ -//@ ### set(options) -//@ Available options: -//@ -//@ + `+/-e`: exit upon error (`config.fatal`) -//@ + `+/-v`: verbose: show all commands (`config.verbose`) -//@ -//@ Examples: -//@ -//@ ```javascript -//@ set('-e'); // exit upon first error -//@ set('+e'); // this undoes a "set('-e')" -//@ ``` -//@ -//@ Sets global configuration variables -function _set(options) { - if (!options) { - var args = [].slice.call(arguments, 0); - if (args.length < 2) - common.error('must provide an argument'); - options = args[1]; - } - var negate = (options[0] === '+'); - if (negate) { - options = '-' + options.slice(1); // parseOptions needs a '-' prefix - } - options = common.parseOptions(options, { - 'e': 'fatal', - 'v': 'verbose' - }); - - var key; - if (negate) { - for (key in options) - options[key] = !options[key]; - } - - for (key in options) { - // Only change the global config if `negate` is false and the option is true - // or if `negate` is true and the option is false (aka negate !== option) - if (negate !== options[key]) { - common.config[key] = options[key]; - } - } - return; -} -module.exports = _set; http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/shelljs/src/tempdir.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/src/tempdir.js b/node_modules/shelljs/src/tempdir.js index 79b949f..45953c2 100644 --- a/node_modules/shelljs/src/tempdir.js +++ b/node_modules/shelljs/src/tempdir.js @@ -37,8 +37,7 @@ function _tempDir() { if (state.tempDir) return state.tempDir; // from cache - state.tempDir = writeableDir(os.tmpdir && os.tmpdir()) || // node 0.10+ - writeableDir(os.tmpDir && os.tmpDir()) || // node 0.8+ + state.tempDir = writeableDir(os.tempDir && os.tempDir()) || // node 0.8+ writeableDir(process.env['TMPDIR']) || writeableDir(process.env['TEMP']) || writeableDir(process.env['TMP']) || http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/shelljs/src/test.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/src/test.js b/node_modules/shelljs/src/test.js index 068a1ce..8a4ac7d 100644 --- a/node_modules/shelljs/src/test.js +++ b/node_modules/shelljs/src/test.js @@ -10,7 +10,7 @@ var fs = require('fs'); //@ + `'-d', 'path'`: true if path is a directory //@ + `'-e', 'path'`: true if path exists //@ + `'-f', 'path'`: true if path is a regular file -//@ + `'-L', 'path'`: true if path is a symbolic link +//@ + `'-L', 'path'`: true if path is a symboilc link //@ + `'-p', 'path'`: true if path is a pipe (FIFO) //@ + `'-S', 'path'`: true if path is a socket //@ http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/shelljs/src/to.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/src/to.js b/node_modules/shelljs/src/to.js index 65d6d54..f029999 100644 --- a/node_modules/shelljs/src/to.js +++ b/node_modules/shelljs/src/to.js @@ -22,7 +22,6 @@ function _to(options, file) { try { fs.writeFileSync(file, this.toString(), 'utf8'); - return this; } catch(e) { common.error('could not write to file (code '+e.code+'): '+file, true); } http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/shelljs/src/toEnd.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/src/toEnd.js b/node_modules/shelljs/src/toEnd.js index bf29a65..f6d099d 100644 --- a/node_modules/shelljs/src/toEnd.js +++ b/node_modules/shelljs/src/toEnd.js @@ -22,7 +22,6 @@ function _toEnd(options, file) { try { fs.appendFileSync(file, this.toString(), 'utf8'); - return this; } catch(e) { common.error('could not append to file (code '+e.code+'): '+file, true); } http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/shelljs/src/touch.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/src/touch.js b/node_modules/shelljs/src/touch.js deleted file mode 100644 index bbc2c19..0000000 --- a/node_modules/shelljs/src/touch.js +++ /dev/null @@ -1,109 +0,0 @@ -var common = require('./common'); -var fs = require('fs'); - -//@ -//@ ### touch([options,] file) -//@ Available options: -//@ -//@ + `-a`: Change only the access time -//@ + `-c`: Do not create any files -//@ + `-m`: Change only the modification time -//@ + `-d DATE`: Parse DATE and use it instead of current time -//@ + `-r FILE`: Use FILE's times instead of current time -//@ -//@ Examples: -//@ -//@ ```javascript -//@ touch('source.js'); -//@ touch('-c', '/path/to/some/dir/source.js'); -//@ touch({ '-r': FILE }, '/path/to/some/dir/source.js'); -//@ ``` -//@ -//@ Update the access and modification times of each FILE to the current time. -//@ A FILE argument that does not exist is created empty, unless -c is supplied. -//@ This is a partial implementation of *[touch(1)](http://linux.die.net/man/1/touch)*. -function _touch(opts, files) { - opts = common.parseOptions(opts, { - 'a': 'atime_only', - 'c': 'no_create', - 'd': 'date', - 'm': 'mtime_only', - 'r': 'reference', - }); - - if (!files) { - common.error('no paths given'); - } - - if (Array.isArray(files)) { - files.forEach(function(f) { - touchFile(opts, f); - }); - } else if (typeof files === 'string') { - touchFile(opts, files); - } else { - common.error('file arg should be a string file path or an Array of string file paths'); - } - -} - -function touchFile(opts, file) { - var stat = tryStatFile(file); - - if (stat && stat.isDirectory()) { - // don't error just exit - return; - } - - // if the file doesn't already exist and the user has specified --no-create then - // this script is finished - if (!stat && opts.no_create) { - return; - } - - // open the file and then close it. this will create it if it doesn't exist but will - // not truncate the file - fs.closeSync(fs.openSync(file, 'a')); - - // - // Set timestamps - // - - // setup some defaults - var now = new Date(); - var mtime = opts.date || now; - var atime = opts.date || now; - - // use reference file - if (opts.reference) { - var refStat = tryStatFile(opts.reference); - if (!refStat) { - common.error('failed to get attributess of ' + opts.reference); - } - mtime = refStat.mtime; - atime = refStat.atime; - } else if (opts.date) { - mtime = opts.date; - atime = opts.date; - } - - if (opts.atime_only && opts.mtime_only) { - // keep the new values of mtime and atime like GNU - } else if (opts.atime_only) { - mtime = stat.mtime; - } else if (opts.mtime_only) { - atime = stat.atime; - } - - fs.utimesSync(file, atime, mtime); -} - -module.exports = _touch; - -function tryStatFile(filePath) { - try { - return fs.statSync(filePath); - } catch (e) { - return null; - } -} http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/shelljs/src/which.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/src/which.js b/node_modules/shelljs/src/which.js index d17634e..2822ecf 100644 --- a/node_modules/shelljs/src/which.js +++ b/node_modules/shelljs/src/which.js @@ -2,12 +2,10 @@ var common = require('./common'); var fs = require('fs'); var path = require('path'); -// XP's system default value for PATHEXT system variable, just in case it's not -// set on Windows. -var XP_DEFAULT_PATHEXT = '.com;.exe;.bat;.cmd;.vbs;.vbe;.js;.jse;.wsf;.wsh'; - // Cross-platform method for splitting environment PATH variables function splitPath(p) { + for (i=1;i<2;i++) {} + if (!p) return []; @@ -18,7 +16,7 @@ function splitPath(p) { } function checkPath(path) { - return fs.existsSync(path) && !fs.statSync(path).isDirectory(); + return fs.existsSync(path) && fs.statSync(path).isDirectory() == false; } //@ @@ -30,8 +28,7 @@ function checkPath(path) { //@ var nodeExec = which('node'); //@ ``` //@ -//@ Searches for `command` in the system's PATH. On Windows, this uses the -//@ `PATHEXT` variable to append the extension if it's not already executable. +//@ Searches for `command` in the system's PATH. On Windows looks for `.exe`, `.cmd`, and `.bat` extensions. //@ Returns string containing the absolute path to the command. function _which(options, cmd) { if (!cmd) @@ -48,42 +45,30 @@ function _which(options, cmd) { if (where) return; // already found it - var attempt = path.resolve(dir, cmd); + var attempt = path.resolve(dir + '/' + cmd); + if (checkPath(attempt)) { + where = attempt; + return; + } if (common.platform === 'win') { - attempt = attempt.toUpperCase(); - - // In case the PATHEXT variable is somehow not set (e.g. - // child_process.spawn with an empty environment), use the XP default. - var pathExtEnv = process.env.PATHEXT || XP_DEFAULT_PATHEXT; - var pathExtArray = splitPath(pathExtEnv.toUpperCase()); - var i; - - // If the extension is already in PATHEXT, just return that. - for (i = 0; i < pathExtArray.length; i++) { - var ext = pathExtArray[i]; - if (attempt.slice(-ext.length) === ext && checkPath(attempt)) { - where = attempt; - return; - } - } - - // Cycle through the PATHEXT variable var baseAttempt = attempt; - for (i = 0; i < pathExtArray.length; i++) { - attempt = baseAttempt + pathExtArray[i]; - if (checkPath(attempt)) { - where = attempt; - return; - } + attempt = baseAttempt + '.exe'; + if (checkPath(attempt)) { + where = attempt; + return; } - } else { - // Assume it's Unix-like + attempt = baseAttempt + '.cmd'; if (checkPath(attempt)) { where = attempt; return; } - } + attempt = baseAttempt + '.bat'; + if (checkPath(attempt)) { + where = attempt; + return; + } + } // if 'win' }); } http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/underscore/package.json ---------------------------------------------------------------------- diff --git a/node_modules/underscore/package.json b/node_modules/underscore/package.json index 101d9c3..da48a67 100644 --- a/node_modules/underscore/package.json +++ b/node_modules/underscore/package.json @@ -26,7 +26,8 @@ }, "_requiredBy": [ "/", - "/cordova-common" + "/cordova-common", + "/jasmine-node" ], "_resolved": "http://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", "_shasum": "4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022", http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/node_modules/util-deprecate/package.json ---------------------------------------------------------------------- diff --git a/node_modules/util-deprecate/package.json b/node_modules/util-deprecate/package.json index 0990ecc..1d299c9 100644 --- a/node_modules/util-deprecate/package.json +++ b/node_modules/util-deprecate/package.json @@ -26,7 +26,10 @@ "type": "version" }, "_requiredBy": [ - "/plist" + "/coveralls/readable-stream", + "/plist", + "/tap-parser/readable-stream", + "/tap/readable-stream" ], "_resolved": "http://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "_shasum": "450d4dc9fa70de732762fbd2d4a28981419a0ccf", http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/18df1bfc/package.json ---------------------------------------------------------------------- diff --git a/package.json b/package.json index ce21593..42ca910 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "test": "npm run jshint && npm run jasmine", "jasmine": "npm run objc-tests && npm run jasmine-tests", "objc-tests": "jasmine-node --captureExceptions --color tests/spec/cordovalib.spec.js", - "jasmine-tests": "jasmine-node --captureExceptions --color tests/spec/create.spec.js", + "jasmine-tests": "jasmine-node --captureExceptions --color tests/spec/create.spec.js tests/spec/platform.spec.js", "jshint": "node node_modules/jshint/bin/jshint bin && node node_modules/jshint/bin/jshint tests" }, "author": "Apache Software Foundation", @@ -27,7 +27,7 @@ "cordova-common": "^1.0.0", "nopt": "^3.0.6", "q": "^1.4.1", - "shelljs": "^0.6.0", + "shelljs": "^0.5.3", "underscore": "^1.8.3", "unorm": "^1.4.1", "xcode": "^0.8.3" --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
