You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2017/05/25 20:38:31 UTC

[11/25] cordova-browser git commit: update shelljs version, prepare is working

http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/set.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/set.js b/node_modules/shelljs/src/set.js
index 19e26d9..238e23e 100644
--- a/node_modules/shelljs/src/set.js
+++ b/node_modules/shelljs/src/set.js
@@ -1,11 +1,17 @@
 var common = require('./common');
 
+common.register('set', _set, {
+  allowGlobbing: false,
+  wrapOutput: false,
+});
+
 //@
 //@ ### set(options)
 //@ Available options:
 //@
 //@ + `+/-e`: exit upon error (`config.fatal`)
 //@ + `+/-v`: verbose: show all commands (`config.verbose`)
+//@ + `+/-f`: disable filename expansion (globbing)
 //@
 //@ Examples:
 //@
@@ -18,8 +24,7 @@ var common = require('./common');
 function _set(options) {
   if (!options) {
     var args = [].slice.call(arguments, 0);
-    if (args.length < 2)
-      common.error('must provide an argument');
+    if (args.length < 2) common.error('must provide an argument');
     options = args[1];
   }
   var negate = (options[0] === '+');
@@ -28,22 +33,23 @@ function _set(options) {
   }
   options = common.parseOptions(options, {
     'e': 'fatal',
-    'v': 'verbose'
+    'v': 'verbose',
+    'f': 'noglob',
   });
 
-  var key;
   if (negate) {
-    for (key in options)
+    Object.keys(options).forEach(function (key) {
       options[key] = !options[key];
+    });
   }
 
-  for (key in options) {
+  Object.keys(options).forEach(function (key) {
     // 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-browser/blob/c846b473/node_modules/shelljs/src/tempdir.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/tempdir.js b/node_modules/shelljs/src/tempdir.js
index 79b949f..a2d15be 100644
--- a/node_modules/shelljs/src/tempdir.js
+++ b/node_modules/shelljs/src/tempdir.js
@@ -2,20 +2,24 @@ var common = require('./common');
 var os = require('os');
 var fs = require('fs');
 
+common.register('tempdir', _tempDir, {
+  allowGlobbing: false,
+  wrapOutput: false,
+});
+
 // Returns false if 'dir' is not a writeable directory, 'dir' otherwise
 function writeableDir(dir) {
-  if (!dir || !fs.existsSync(dir))
-    return false;
+  if (!dir || !fs.existsSync(dir)) return false;
 
-  if (!fs.statSync(dir).isDirectory())
-    return false;
+  if (!fs.statSync(dir).isDirectory()) return false;
 
-  var testFile = dir+'/'+common.randomFileName();
+  var testFile = dir + '/' + common.randomFileName();
   try {
     fs.writeFileSync(testFile, ' ');
     common.unlinkSync(testFile);
     return dir;
   } catch (e) {
+    /* istanbul ignore next */
     return false;
   }
 }
@@ -34,15 +38,14 @@ function writeableDir(dir) {
 //@ Follows Python's [tempfile algorithm](http://docs.python.org/library/tempfile.html#tempfile.tempdir).
 function _tempDir() {
   var state = common.state;
-  if (state.tempDir)
-    return state.tempDir; // from cache
+  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+
-                  writeableDir(process.env['TMPDIR']) ||
-                  writeableDir(process.env['TEMP']) ||
-                  writeableDir(process.env['TMP']) ||
-                  writeableDir(process.env['Wimp$ScrapDir']) || // RiscOS
+                  writeableDir(process.env.TMPDIR) ||
+                  writeableDir(process.env.TEMP) ||
+                  writeableDir(process.env.TMP) ||
+                  writeableDir(process.env.Wimp$ScrapDir) || // RiscOS
                   writeableDir('C:\\TEMP') || // Windows
                   writeableDir('C:\\TMP') || // Windows
                   writeableDir('\\TEMP') || // Windows

http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/test.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/test.js b/node_modules/shelljs/src/test.js
index 068a1ce..d3d9c07 100644
--- a/node_modules/shelljs/src/test.js
+++ b/node_modules/shelljs/src/test.js
@@ -1,6 +1,22 @@
 var common = require('./common');
 var fs = require('fs');
 
+common.register('test', _test, {
+  cmdOptions: {
+    'b': 'block',
+    'c': 'character',
+    'd': 'directory',
+    'e': 'exists',
+    'f': 'file',
+    'L': 'link',
+    'p': 'pipe',
+    'S': 'socket',
+  },
+  wrapOutput: false,
+  allowGlobbing: false,
+});
+
+
 //@
 //@ ### test(expression)
 //@ Available expression primaries:
@@ -23,63 +39,46 @@ var fs = require('fs');
 //@
 //@ Evaluates expression using the available primaries and returns corresponding value.
 function _test(options, path) {
-  if (!path)
-    common.error('no path given');
-
-  // hack - only works with unary primaries
-  options = common.parseOptions(options, {
-    'b': 'block',
-    'c': 'character',
-    'd': 'directory',
-    'e': 'exists',
-    'f': 'file',
-    'L': 'link',
-    'p': 'pipe',
-    'S': 'socket'
-  });
+  if (!path) common.error('no path given');
 
   var canInterpret = false;
-  for (var key in options)
+  Object.keys(options).forEach(function (key) {
     if (options[key] === true) {
       canInterpret = true;
-      break;
     }
+  });
 
-  if (!canInterpret)
-    common.error('could not interpret expression');
+  if (!canInterpret) common.error('could not interpret expression');
 
   if (options.link) {
     try {
       return fs.lstatSync(path).isSymbolicLink();
-    } catch(e) {
+    } catch (e) {
       return false;
     }
   }
 
-  if (!fs.existsSync(path))
-    return false;
+  if (!fs.existsSync(path)) return false;
 
-  if (options.exists)
-    return true;
+  if (options.exists) return true;
 
   var stats = fs.statSync(path);
 
-  if (options.block)
-    return stats.isBlockDevice();
+  if (options.block) return stats.isBlockDevice();
+
+  if (options.character) return stats.isCharacterDevice();
 
-  if (options.character)
-    return stats.isCharacterDevice();
+  if (options.directory) return stats.isDirectory();
 
-  if (options.directory)
-    return stats.isDirectory();
+  if (options.file) return stats.isFile();
 
-  if (options.file)
-    return stats.isFile();
+  /* istanbul ignore next */
+  if (options.pipe) return stats.isFIFO();
 
-  if (options.pipe)
-    return stats.isFIFO();
+  /* istanbul ignore next */
+  if (options.socket) return stats.isSocket();
 
-  if (options.socket)
-    return stats.isSocket();
+  /* istanbul ignore next */
+  return false; // fallback
 } // test
 module.exports = _test;

http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/to.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/to.js b/node_modules/shelljs/src/to.js
index 65d6d54..d3d9e37 100644
--- a/node_modules/shelljs/src/to.js
+++ b/node_modules/shelljs/src/to.js
@@ -2,8 +2,13 @@ var common = require('./common');
 var fs = require('fs');
 var path = require('path');
 
+common.register('to', _to, {
+  pipeOnly: true,
+  wrapOutput: false,
+});
+
 //@
-//@ ### 'string'.to(file)
+//@ ### ShellString.prototype.to(file)
 //@
 //@ Examples:
 //@
@@ -11,20 +16,22 @@ var path = require('path');
 //@ cat('input.txt').to('output.txt');
 //@ ```
 //@
-//@ Analogous to the redirection operator `>` in Unix, but works with JavaScript strings (such as
-//@ those returned by `cat`, `grep`, etc). _Like Unix redirections, `to()` will overwrite any existing file!_
+//@ Analogous to the redirection operator `>` in Unix, but works with
+//@ ShellStrings (such as those returned by `cat`, `grep`, etc). _Like Unix
+//@ redirections, `to()` will overwrite any existing file!_
 function _to(options, file) {
-  if (!file)
-    common.error('wrong arguments');
+  if (!file) common.error('wrong arguments');
 
-  if (!fs.existsSync( path.dirname(file) ))
-      common.error('no such file or directory: ' + path.dirname(file));
+  if (!fs.existsSync(path.dirname(file))) {
+    common.error('no such file or directory: ' + path.dirname(file));
+  }
 
   try {
-    fs.writeFileSync(file, this.toString(), 'utf8');
+    fs.writeFileSync(file, this.stdout || this.toString(), 'utf8');
     return this;
-  } catch(e) {
-    common.error('could not write to file (code '+e.code+'): '+file, true);
+  } catch (e) {
+    /* istanbul ignore next */
+    common.error('could not write to file (code ' + e.code + '): ' + file, { continue: true });
   }
 }
 module.exports = _to;

http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/toEnd.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/toEnd.js b/node_modules/shelljs/src/toEnd.js
index bf29a65..dc165fe 100644
--- a/node_modules/shelljs/src/toEnd.js
+++ b/node_modules/shelljs/src/toEnd.js
@@ -2,8 +2,13 @@ var common = require('./common');
 var fs = require('fs');
 var path = require('path');
 
+common.register('toEnd', _toEnd, {
+  pipeOnly: true,
+  wrapOutput: false,
+});
+
 //@
-//@ ### 'string'.toEnd(file)
+//@ ### ShellString.prototype.toEnd(file)
 //@
 //@ Examples:
 //@
@@ -11,20 +16,21 @@ var path = require('path');
 //@ cat('input.txt').toEnd('output.txt');
 //@ ```
 //@
-//@ Analogous to the redirect-and-append operator `>>` in Unix, but works with JavaScript strings (such as
-//@ those returned by `cat`, `grep`, etc).
+//@ Analogous to the redirect-and-append operator `>>` in Unix, but works with
+//@ ShellStrings (such as those returned by `cat`, `grep`, etc).
 function _toEnd(options, file) {
-  if (!file)
-    common.error('wrong arguments');
+  if (!file) common.error('wrong arguments');
 
-  if (!fs.existsSync( path.dirname(file) ))
-      common.error('no such file or directory: ' + path.dirname(file));
+  if (!fs.existsSync(path.dirname(file))) {
+    common.error('no such file or directory: ' + path.dirname(file));
+  }
 
   try {
-    fs.appendFileSync(file, this.toString(), 'utf8');
+    fs.appendFileSync(file, this.stdout || this.toString(), 'utf8');
     return this;
-  } catch(e) {
-    common.error('could not append to file (code '+e.code+'): '+file, true);
+  } catch (e) {
+    /* istanbul ignore next */
+    common.error('could not append to file (code ' + e.code + '): ' + file, { continue: true });
   }
 }
 module.exports = _toEnd;

http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/touch.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/touch.js b/node_modules/shelljs/src/touch.js
index bbc2c19..b672b2d 100644
--- a/node_modules/shelljs/src/touch.js
+++ b/node_modules/shelljs/src/touch.js
@@ -1,8 +1,19 @@
 var common = require('./common');
 var fs = require('fs');
 
+common.register('touch', _touch, {
+  cmdOptions: {
+    'a': 'atime_only',
+    'c': 'no_create',
+    'd': 'date',
+    'm': 'mtime_only',
+    'r': 'reference',
+  },
+});
+
 //@
-//@ ### touch([options,] file)
+//@ ### touch([options,] file [, file ...])
+//@ ### touch([options,] file_array)
 //@ Available options:
 //@
 //@ + `-a`: Change only the access time
@@ -23,28 +34,18 @@ var fs = require('fs');
 //@ 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);
-    });
+    common.error('no files given');
   } else if (typeof files === 'string') {
-    touchFile(opts, files);
+    files = [].slice.call(arguments, 1);
   } else {
     common.error('file arg should be a string file path or an Array of string file paths');
   }
 
+  files.forEach(function (f) {
+    touchFile(opts, f);
+  });
+  return '';
 }
 
 function touchFile(opts, file) {

http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/which.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/which.js b/node_modules/shelljs/src/which.js
index d17634e..03db57b 100644
--- a/node_modules/shelljs/src/which.js
+++ b/node_modules/shelljs/src/which.js
@@ -2,23 +2,24 @@ var common = require('./common');
 var fs = require('fs');
 var path = require('path');
 
+common.register('which', _which, {
+  allowGlobbing: false,
+  cmdOptions: {
+    'a': 'all',
+  },
+});
+
 // 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) {
-  if (!p)
-    return [];
-
-  if (common.platform === 'win')
-    return p.split(';');
-  else
-    return p.split(':');
+  return p ? p.split(path.delimiter) : [];
 }
 
-function checkPath(path) {
-  return fs.existsSync(path) && !fs.statSync(path).isDirectory();
+function checkPath(pathName) {
+  return fs.existsSync(pathName) && !fs.statSync(pathName).isDirectory();
 }
 
 //@
@@ -34,65 +35,64 @@ function checkPath(path) {
 //@ `PATHEXT` variable to append the extension if it's not already executable.
 //@ Returns string containing the absolute path to the command.
 function _which(options, cmd) {
-  if (!cmd)
-    common.error('must specify command');
+  if (!cmd) common.error('must specify command');
 
-  var pathEnv = process.env.path || process.env.Path || process.env.PATH,
-      pathArray = splitPath(pathEnv),
-      where = null;
+  var pathEnv = process.env.path || process.env.Path || process.env.PATH;
+  var pathArray = splitPath(pathEnv);
+
+  var queryMatches = [];
 
   // No relative/absolute paths provided?
-  if (cmd.search(/\//) === -1) {
+  if (cmd.indexOf('/') === -1) {
+    // Assume that there are no extensions to append to queries (this is the
+    // case for unix)
+    var pathExtArray = [''];
+    if (common.platform === 'win') {
+      // 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;
+      pathExtArray = splitPath(pathExtEnv.toUpperCase());
+    }
+
     // Search for command in PATH
-    pathArray.forEach(function(dir) {
-      if (where)
-        return; // already found it
+    for (var k = 0; k < pathArray.length; k++) {
+      // already found it
+      if (queryMatches.length > 0 && !options.all) break;
 
-      var attempt = path.resolve(dir, cmd);
+      var attempt = path.resolve(pathArray[k], cmd);
 
       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;
-          }
+      var match = attempt.match(/\.[^<>:"/\|?*.]+$/);
+      if (match && pathExtArray.indexOf(match[0]) >= 0) { // this is Windows-only
+        // The user typed a query with the file extension, like
+        // `which('node.exe')`
+        if (checkPath(attempt)) {
+          queryMatches.push(attempt);
+          break;
         }
-
-        // 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;
+      } else { // All-platforms
+        // Cycle through the PATHEXT array, and check each extension
+        // Note: the array is always [''] on Unix
+        for (var i = 0; i < pathExtArray.length; i++) {
+          var ext = pathExtArray[i];
+          var newAttempt = attempt + ext;
+          if (checkPath(newAttempt)) {
+            queryMatches.push(newAttempt);
+            break;
           }
         }
-      } else {
-        // Assume it's Unix-like
-        if (checkPath(attempt)) {
-          where = attempt;
-          return;
-        }
       }
-    });
+    }
+  } else if (checkPath(cmd)) { // a valid absolute or relative path
+    queryMatches.push(path.resolve(cmd));
   }
 
-  // Command not found anywhere?
-  if (!checkPath(cmd) && !where)
-    return null;
-
-  where = where || path.resolve(cmd);
-
-  return common.ShellString(where);
+  if (queryMatches.length > 0) {
+    return options.all ? queryMatches : queryMatches[0];
+  }
+  return options.all ? [] : null;
 }
 module.exports = _which;

http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 76b3f70..5974095 100644
--- a/package.json
+++ b/package.json
@@ -24,7 +24,7 @@
     "cordova-serve": "^1.0.0",
     "nopt": "^3.0.6",
     "q": "^1.4.1",
-    "shelljs": "^0.6.0"
+    "shelljs": "^0.7.7"
   },
   "devDependencies": {
     "jasmine": "^2.5.3",


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org