]> git.parisson.com Git - pdf.js.git/commitdiff
bumping ShellJS
authorArtur Adib <arturadib@gmail.com>
Wed, 28 Mar 2012 22:03:31 +0000 (18:03 -0400)
committerArtur Adib <arturadib@gmail.com>
Wed, 28 Mar 2012 22:03:31 +0000 (18:03 -0400)
external/shelljs/README.md
external/shelljs/make.js
external/shelljs/package.json
external/shelljs/shell.js

index 9f5386efe7f798c252c4208e6bdbe26a8fb00487..af5f05127d17117d5ec07f531b4caab62634d58f 100644 (file)
@@ -138,7 +138,7 @@ Examples:
 ```javascript
 find('src', 'lib');
 find(['src', 'lib']); // same as above
-find('.').filter(function(file) { return file.match(/\.js$/); })
+find('.').filter(function(file) { return file.match(/\.js$/); });
 ```
 
 Returns array of all files (however deep) in the given paths.
@@ -325,6 +325,10 @@ When in synchronous mode returns the object `{ code:..., output:... }`, containi
 `output` (stdout + stderr)  and its exit `code`. Otherwise 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
+fixed soon.
+
 ## Non-Unix commands
 
 
@@ -346,7 +350,8 @@ silent(true);
 silent(silentState); // restore old silent state
 ```
 
-Suppresses all output if `state = true`. Returns state if no arguments given.
+Suppresses all command output if `state = true`, except for `echo()` calls. 
+Returns state if no arguments given.
 
 ## Deprecated
 
index 9c92dadc80f24627ebde5fe8b96d43e8d7bc8673..c495735bf2875c63699fc4cad615e4baa8409de9 100644 (file)
@@ -23,7 +23,7 @@ setTimeout(function() {
         if (oldTarget.done && !force)
           return;
         oldTarget.done = true;
-        return oldTarget(arguments);
+        return oldTarget.apply(oldTarget, arguments);
       }
 
     })(t, target[t]);
index 99c0f5e6490d244488568c24f15305ff71e4a267..4d2830cb922fbef684a7fb2178edb7f8416e1866 100644 (file)
@@ -1,12 +1,29 @@
-{ "name": "shelljs"
-, "version": "0.0.5pre2"
-, "author": "Artur Adib <aadib@mozilla.com>"
-, "description": "Portable Unix shell commands for Node.js"
-, "keywords": ["unix", "shell", "makefile", "make", "jake", "synchronous"]
-, "repository": "git://github.com/arturadib/shelljs"
-, "homepage": "http://github.com/arturadib/shelljs"
-, "main": "./shell.js"
-, "scripts": {
+{
+  "name": "shelljs",
+  "version": "0.0.5pre4",
+  "author": "Artur Adib <aadib@mozilla.com>",
+  "description": "Portable Unix shell commands for Node.js",
+  "keywords": [
+    "unix",
+    "shell",
+    "makefile",
+    "make",
+    "jake",
+    "synchronous"
+  ],
+  "repository": {
+    "type": "git",
+    "url": "git://github.com/arturadib/shelljs.git"
+  },
+  "homepage": "http://github.com/arturadib/shelljs",
+  "main": "./shell.js",
+  "scripts": {
     "test": "node scripts/run-tests"
+  },
+  "dependencies": {},
+  "devDependencies": {},
+  "optionalDependencies": {},
+  "engines": {
+    "node": "*"
   }
 }
index 9c1181fb618812e3fb9d2d7a583eb400c4da967d..92c49c54d361ecbdc8258d533831b91201d7a2c3 100644 (file)
@@ -777,7 +777,7 @@ exports.which = wrap('which', _which);
 //@ like `.to()`.
 function _echo(options) {
   var messages = [].slice.call(arguments, 1);
-  log.apply(this, messages);
+  console.log.apply(this, messages);
   return ShellString(messages.join(' '));
 };
 exports.echo = wrap('echo', _echo);
@@ -809,6 +809,10 @@ exports.env = process.env;
 //@ When in synchronous mode returns the object `{ code:..., output:... }`, containing the program's 
 //@ `output` (stdout + stderr)  and its exit `code`. Otherwise 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
+//@ fixed soon.
 function _exec(command, options, callback) {
   if (!command)
     error('must specify command');
@@ -868,7 +872,8 @@ exports.error = function() {
 //@ silent(silentState); // restore old silent state
 //@ ```
 //@
-//@ Suppresses all output if `state = true`. Returns state if no arguments given.
+//@ Suppresses all command output if `state = true`, except for `echo()` calls. 
+//@ Returns state if no arguments given.
 exports.silent = function(_state) {
   if (typeof _state !== 'boolean')
     return state.silent;
@@ -1020,7 +1025,7 @@ function wrap(cmd, fn, options) {
     } catch (e) {
       if (!state.error) {
         // If state.error hasn't been set it's an error thrown by Node, not us - probably a bug...
-        console.log('maker.js: internal error');
+        console.log('shell.js: internal error');
         console.log(e.stack || e);
         process.exit(1);
       }
@@ -1028,7 +1033,7 @@ function wrap(cmd, fn, options) {
         throw e;
     }
 
-    state.currentCmd = 'maker.js';
+    state.currentCmd = 'shell.js';
     return retValue;
   }
 } // wrap
@@ -1151,8 +1156,7 @@ function rmdirSyncRecursive(dir, force) {
   try {
     result = fs.rmdirSync(dir);
   } catch(e) {
-    if (e.code === 'ENOTEMPTY')
-      error('directory not empty: ' + dir, true);
+    error('could not remove directory (code '+e.code+'): ' + dir, true);
   }
 
   return result;
@@ -1234,8 +1238,11 @@ function tempDir() {
 
 // Wrapper around exec() to enable echoing output to console in real time
 function execAsync(cmd, opts, callback) {
-  var output = '',
-      silent = 'silent' in opts ? opts.silent : state.silent;
+  var output = '';
+
+  var options = extend({
+    silent: state.silent
+  }, opts);
   
   var c = child.exec(cmd, {env: process.env}, function(err) {
     if (callback) 
@@ -1244,14 +1251,14 @@ function execAsync(cmd, opts, callback) {
 
   c.stdout.on('data', function(data) {
     output += data;
-    if (!silent)
-      write(data);
+    if (!options.silent)
+      process.stdout.write(data);
   });
 
   c.stderr.on('data', function(data) {
     output += data;
-    if (!silent)
-      write(data);
+    if (!options.silent)
+      process.stdout.write(data);
   });
 }
 
@@ -1325,11 +1332,12 @@ function execSync(cmd, opts) {
 
   var stdout = fs.readFileSync(stdoutFile, 'utf8');
 
-  _unlinkSync(scriptFile);
-  _unlinkSync(stdoutFile);
-  _unlinkSync(codeFile);
-  _unlinkSync(sleepFile);
-
+  // No biggie if we can't erase the files now -- they're in a temp dir anyway
+  try { _unlinkSync(scriptFile); } catch(e) {};
+  try { _unlinkSync(stdoutFile); } catch(e) {};
+  try { _unlinkSync(codeFile); } catch(e) {};
+  try { _unlinkSync(sleepFile); } catch(e) {};
+  
   // True if successful, false if not
   var obj = {
     code: code,