Repository: cordova-browser Updated Branches: refs/heads/master 6effec380 -> 5530c41e9
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/mkdir.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/mkdir.js b/node_modules/shelljs/test/mkdir.js new file mode 100644 index 0000000..1f93422 --- /dev/null +++ b/node_modules/shelljs/test/mkdir.js @@ -0,0 +1,79 @@ +var shell = require('..'); + +var assert = require('assert'), + path = require('path'), + fs = require('fs'); + +// Node shims for < v0.7 +fs.existsSync = fs.existsSync || path.existsSync; + +shell.config.silent = true; + +function numLines(str) { + return typeof str === 'string' ? str.match(/\n/g).length : 0; +} + +shell.rm('-rf', 'tmp'); +shell.mkdir('tmp'); + +// +// Invalids +// + +shell.mkdir(); +assert.ok(shell.error()); + +var mtime = fs.statSync('tmp').mtime.toString(); +shell.mkdir('tmp'); // dir already exists +assert.ok(shell.error()); +assert.equal(fs.statSync('tmp').mtime.toString(), mtime); // didn't mess with dir + +assert.equal(fs.existsSync('/asdfasdf'), false); // sanity check +shell.mkdir('/asdfasdf/asdfasdf'); // root path does not exist +assert.ok(shell.error()); +assert.equal(fs.existsSync('/asdfasdf'), false); + +// +// Valids +// + +assert.equal(fs.existsSync('tmp/t1'), false); +shell.mkdir('tmp/t1'); // simple dir +assert.equal(shell.error(), null); +assert.equal(fs.existsSync('tmp/t1'), true); + +assert.equal(fs.existsSync('tmp/t2'), false); +assert.equal(fs.existsSync('tmp/t3'), false); +shell.mkdir('tmp/t2', 'tmp/t3'); // multiple dirs +assert.equal(shell.error(), null); +assert.equal(fs.existsSync('tmp/t2'), true); +assert.equal(fs.existsSync('tmp/t3'), true); + +assert.equal(fs.existsSync('tmp/t1'), true); +assert.equal(fs.existsSync('tmp/t4'), false); +shell.mkdir('tmp/t1', 'tmp/t4'); // one dir exists, one doesn't +assert.equal(numLines(shell.error()), 1); +assert.equal(fs.existsSync('tmp/t1'), true); +assert.equal(fs.existsSync('tmp/t4'), true); + +assert.equal(fs.existsSync('tmp/a'), false); +shell.mkdir('-p', 'tmp/a/b/c'); +assert.equal(shell.error(), null); +assert.equal(fs.existsSync('tmp/a/b/c'), true); +shell.rm('-Rf', 'tmp/a'); // revert + +// multiple dirs +shell.mkdir('-p', 'tmp/zzza', 'tmp/zzzb', 'tmp/zzzc'); +assert.equal(shell.error(), null); +assert.equal(fs.existsSync('tmp/zzza'), true); +assert.equal(fs.existsSync('tmp/zzzb'), true); +assert.equal(fs.existsSync('tmp/zzzc'), true); + +// multiple dirs, array syntax +shell.mkdir('-p', ['tmp/yyya', 'tmp/yyyb', 'tmp/yyyc']); +assert.equal(shell.error(), null); +assert.equal(fs.existsSync('tmp/yyya'), true); +assert.equal(fs.existsSync('tmp/yyyb'), true); +assert.equal(fs.existsSync('tmp/yyyc'), true); + +shell.exit(123); http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/mv.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/mv.js b/node_modules/shelljs/test/mv.js new file mode 100644 index 0000000..89bca91 --- /dev/null +++ b/node_modules/shelljs/test/mv.js @@ -0,0 +1,130 @@ +var shell = require('..'); + +var assert = require('assert'), + path = require('path'), + fs = require('fs'); + +// Node shims for < v0.7 +fs.existsSync = fs.existsSync || path.existsSync; + +shell.config.silent = true; + +function numLines(str) { + return typeof str === 'string' ? str.match(/\n/g).length : 0; +} + +shell.rm('-rf', 'tmp'); +shell.mkdir('tmp'); + +// Prepare tmp/ +shell.cp('resources/*', 'tmp'); + +// +// Invalids +// + +shell.mv(); +assert.ok(shell.error()); + +shell.mv('file1'); +assert.ok(shell.error()); + +shell.mv('-f'); +assert.ok(shell.error()); + +shell.mv('-Z', 'tmp/file1', 'tmp/file1'); // option not supported +assert.ok(shell.error()); +assert.equal(fs.existsSync('tmp/file1'), true); + +shell.mv('asdfasdf', 'tmp'); // source does not exist +assert.ok(shell.error()); +assert.equal(numLines(shell.error()), 1); +assert.equal(fs.existsSync('tmp/asdfasdf'), false); + +shell.mv('asdfasdf1', 'asdfasdf2', 'tmp'); // sources do not exist +assert.ok(shell.error()); +assert.equal(numLines(shell.error()), 2); +assert.equal(fs.existsSync('tmp/asdfasdf1'), false); +assert.equal(fs.existsSync('tmp/asdfasdf2'), false); + +shell.mv('asdfasdf1', 'asdfasdf2', 'tmp/file1'); // too many sources (dest is file) +assert.ok(shell.error()); + +shell.mv('tmp/file1', 'tmp/file2'); // dest already exists +assert.ok(shell.error()); + +shell.mv('tmp/file1', 'tmp/file2', 'tmp/a_file'); // too many sources (exist, but dest is file) +assert.ok(shell.error()); +assert.equal(fs.existsSync('tmp/a_file'), false); + +shell.mv('tmp/file*', 'tmp/file1'); // can't use wildcard when dest is file +assert.ok(shell.error()); +assert.equal(fs.existsSync('tmp/file1'), true); +assert.equal(fs.existsSync('tmp/file2'), true); +assert.equal(fs.existsSync('tmp/file1.js'), true); +assert.equal(fs.existsSync('tmp/file2.js'), true); + +// +// Valids +// + +shell.cd('tmp'); + +// handles self OK +shell.mkdir('tmp2'); +shell.mv('*', 'tmp2'); // has to handle self (tmp2 --> tmp2) without throwing error +assert.ok(shell.error()); // there's an error, but not fatal +assert.equal(fs.existsSync('tmp2/file1'), true); // moved OK +shell.mv('tmp2/*', '.'); // revert +assert.equal(fs.existsSync('file1'), true); // moved OK + +shell.mv('file1', 'file3'); // one source +assert.equal(shell.error(), null); +assert.equal(fs.existsSync('file1'), false); +assert.equal(fs.existsSync('file3'), true); +shell.mv('file3', 'file1'); // revert +assert.equal(shell.error(), null); +assert.equal(fs.existsSync('file1'), true); + +// two sources +shell.rm('-rf', 't'); +shell.mkdir('-p', 't'); +shell.mv('file1', 'file2', 't'); +assert.equal(shell.error(), null); +assert.equal(fs.existsSync('file1'), false); +assert.equal(fs.existsSync('file2'), false); +assert.equal(fs.existsSync('t/file1'), true); +assert.equal(fs.existsSync('t/file2'), true); +shell.mv('t/*', '.'); // revert +assert.equal(fs.existsSync('file1'), true); +assert.equal(fs.existsSync('file2'), true); + +// two sources, array style +shell.rm('-rf', 't'); +shell.mkdir('-p', 't'); +shell.mv(['file1', 'file2'], 't'); // two sources +assert.equal(shell.error(), null); +assert.equal(fs.existsSync('file1'), false); +assert.equal(fs.existsSync('file2'), false); +assert.equal(fs.existsSync('t/file1'), true); +assert.equal(fs.existsSync('t/file2'), true); +shell.mv('t/*', '.'); // revert +assert.equal(fs.existsSync('file1'), true); +assert.equal(fs.existsSync('file2'), true); + +shell.mv('file*.js', 't'); // wildcard +assert.equal(shell.error(), null); +assert.equal(fs.existsSync('file1.js'), false); +assert.equal(fs.existsSync('file2.js'), false); +assert.equal(fs.existsSync('t/file1.js'), true); +assert.equal(fs.existsSync('t/file2.js'), true); +shell.mv('t/*', '.'); // revert +assert.equal(fs.existsSync('file1.js'), true); +assert.equal(fs.existsSync('file2.js'), true); + +shell.mv('-f', 'file1', 'file2'); // dest exists, but -f given +assert.equal(shell.error(), null); +assert.equal(fs.existsSync('file1'), false); +assert.equal(fs.existsSync('file2'), true); + +shell.exit(123); http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/popd.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/popd.js b/node_modules/shelljs/test/popd.js new file mode 100644 index 0000000..fd79533 --- /dev/null +++ b/node_modules/shelljs/test/popd.js @@ -0,0 +1,118 @@ +var shell = require('..'); + +var assert = require('assert'), + path = require('path'), + fs = require('fs'); + +// Node shims for < v0.7 +fs.existsSync = fs.existsSync || path.existsSync; + +shell.config.silent = true; + +var root = path.resolve(), trail; + +function reset() { + shell.dirs('-c'); + shell.cd(root); +} + +// Valid +shell.pushd('resources/pushd'); +trail = shell.popd(); +assert.equal(shell.error(), null); +assert.equal(process.cwd(), trail[0]); +assert.deepEqual(trail, [ root ]); + +shell.pushd('resources/pushd'); +shell.pushd('a'); +trail = shell.popd(); +assert.equal(shell.error(), null); +assert.equal(process.cwd(), trail[0]); +assert.deepEqual(trail, [ + path.resolve(root, 'resources/pushd'), + root +]); + +shell.pushd('b'); +trail = shell.popd(); +assert.equal(shell.error(), null); +assert.equal(process.cwd(), trail[0]); +assert.deepEqual(trail, [ + path.resolve(root, 'resources/pushd'), + root +]); + +shell.pushd('b'); +shell.pushd('c'); +trail = shell.popd(); +assert.equal(shell.error(), null); +assert.equal(process.cwd(), trail[0]); +assert.deepEqual(trail, [ + path.resolve(root, 'resources/pushd/b'), + path.resolve(root, 'resources/pushd'), + root +]); + +trail = shell.popd(); +assert.equal(shell.error(), null); +assert.equal(process.cwd(), trail[0]); +assert.deepEqual(trail, [ + path.resolve(root, 'resources/pushd'), + root +]); + +trail = shell.popd(); +assert.equal(shell.error(), null); +assert.equal(trail.length, 1); +assert.equal(process.cwd(), trail[0]); +assert.deepEqual(trail, [ root ]); + +// Valid by index +shell.pushd('resources/pushd'); +trail = shell.popd('+0'); +assert.equal(shell.error(), null); +assert.equal(process.cwd(), trail[0]); +assert.deepEqual(trail, [ root ]); + +shell.pushd('resources/pushd'); +trail = shell.popd('+1'); +assert.equal(shell.error(), null); +assert.equal(process.cwd(), trail[0]); +assert.deepEqual(trail, [ path.resolve(root, 'resources/pushd') ]); + +reset(); shell.pushd('resources/pushd'); +trail = shell.popd('-0'); +assert.equal(shell.error(), null); +assert.equal(process.cwd(), trail[0]); +assert.deepEqual(trail, [ path.resolve(root, 'resources/pushd') ]); + +reset(); shell.pushd('resources/pushd'); +trail = shell.popd('-1'); +assert.equal(shell.error(), null); +assert.equal(process.cwd(), trail[0]); +assert.deepEqual(trail, [ root ]); + + +reset(); shell.pushd('resources/pushd'); +trail = shell.popd('-n'); +assert.equal(shell.error(), null); +assert.equal(process.cwd(), trail[0]); +assert.deepEqual(trail, [ path.resolve(root, 'resources/pushd') ]); + +// Invalid +trail = shell.popd(); +assert.ok(shell.error('popd: directory stack empty\n')); + +// Test that the root dir is not stored +shell.cd('resources/pushd'); +shell.pushd('b'); +trail = shell.popd(); +assert.equal(shell.error(), null); +assert.equal(trail[0], path.resolve(root, 'resources/pushd')); +assert.equal(process.cwd(), trail[0]); +shell.popd(); +assert.ok(shell.error(), null); + +shell.cd(root); + +shell.exit(123); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/pushd.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/pushd.js b/node_modules/shelljs/test/pushd.js new file mode 100644 index 0000000..32089dc --- /dev/null +++ b/node_modules/shelljs/test/pushd.js @@ -0,0 +1,228 @@ +var shell = require('..'); + +var assert = require('assert'), + path = require('path'), + fs = require('fs'); + +// Node shims for < v0.7 +fs.existsSync = fs.existsSync || path.existsSync; + +shell.config.silent = true; + +var root = path.resolve(), trail; + +function reset() { + shell.dirs('-c'); + shell.cd(root); +} + +// Push valid directories +trail = shell.pushd('resources/pushd'); +assert.equal(shell.error(), null); +assert.equal(process.cwd(), trail[0]); +assert.deepEqual(trail, [ + path.resolve(root, 'resources/pushd'), + root +]); + +trail = shell.pushd('a'); +assert.equal(shell.error(), null); +assert.equal(process.cwd(), trail[0]); +assert.deepEqual(trail, [ + path.resolve(root, 'resources/pushd/a'), + path.resolve(root, 'resources/pushd'), + root +]); + +trail = shell.pushd('../b'); +assert.equal(shell.error(), null); +assert.equal(process.cwd(), trail[0]); +assert.deepEqual(trail, [ + path.resolve(root, 'resources/pushd/b'), + path.resolve(root, 'resources/pushd/a'), + path.resolve(root, 'resources/pushd'), + root +]); + +trail = shell.pushd('c'); +assert.equal(shell.error(), null); +assert.equal(process.cwd(), trail[0]); +assert.deepEqual(trail, [ + path.resolve(root, 'resources/pushd/b/c'), + path.resolve(root, 'resources/pushd/b'), + path.resolve(root, 'resources/pushd/a'), + path.resolve(root, 'resources/pushd'), + root +]); + +// Push stuff around with positive indices +trail = shell.pushd('+0'); +assert.equal(shell.error(), null); +assert.equal(process.cwd(), trail[0]); +assert.deepEqual(trail, [ + path.resolve(root, 'resources/pushd/b/c'), + path.resolve(root, 'resources/pushd/b'), + path.resolve(root, 'resources/pushd/a'), + path.resolve(root, 'resources/pushd'), + root +]); + +trail = shell.pushd('+1'); +assert.equal(shell.error(), null); +assert.equal(process.cwd(), trail[0]); +assert.deepEqual(trail, [ + path.resolve(root, 'resources/pushd/b'), + path.resolve(root, 'resources/pushd/a'), + path.resolve(root, 'resources/pushd'), + root, + path.resolve(root, 'resources/pushd/b/c') +]); + +trail = shell.pushd('+2'); +assert.equal(shell.error(), null); +assert.equal(process.cwd(), trail[0]); +assert.deepEqual(trail, [ + path.resolve(root, 'resources/pushd'), + root, + path.resolve(root, 'resources/pushd/b/c'), + path.resolve(root, 'resources/pushd/b'), + path.resolve(root, 'resources/pushd/a') +]); + +trail = shell.pushd('+3'); +assert.equal(shell.error(), null); +assert.equal(process.cwd(), trail[0]); +assert.deepEqual(trail, [ + path.resolve(root, 'resources/pushd/b'), + path.resolve(root, 'resources/pushd/a'), + path.resolve(root, 'resources/pushd'), + root, + path.resolve(root, 'resources/pushd/b/c') +]); + +trail = shell.pushd('+4'); +assert.equal(shell.error(), null); +assert.equal(process.cwd(), trail[0]); +assert.deepEqual(trail, [ + path.resolve(root, 'resources/pushd/b/c'), + path.resolve(root, 'resources/pushd/b'), + path.resolve(root, 'resources/pushd/a'), + path.resolve(root, 'resources/pushd'), + root +]); + +// Push stuff around with negative indices +trail = shell.pushd('-0'); +assert.equal(shell.error(), null); +assert.equal(process.cwd(), trail[0]); +assert.deepEqual(trail, [ + root, + path.resolve(root, 'resources/pushd/b/c'), + path.resolve(root, 'resources/pushd/b'), + path.resolve(root, 'resources/pushd/a'), + path.resolve(root, 'resources/pushd') +]); + +trail = shell.pushd('-1'); +assert.equal(shell.error(), null); +assert.equal(process.cwd(), trail[0]); +assert.deepEqual(trail, [ + path.resolve(root, 'resources/pushd/a'), + path.resolve(root, 'resources/pushd'), + root, + path.resolve(root, 'resources/pushd/b/c'), + path.resolve(root, 'resources/pushd/b') +]); + +trail = shell.pushd('-2'); +assert.equal(shell.error(), null); +assert.equal(process.cwd(), trail[0]); +assert.deepEqual(trail, [ + root, + path.resolve(root, 'resources/pushd/b/c'), + path.resolve(root, 'resources/pushd/b'), + path.resolve(root, 'resources/pushd/a'), + path.resolve(root, 'resources/pushd') +]); + +trail = shell.pushd('-3'); +assert.equal(shell.error(), null); +assert.equal(process.cwd(), trail[0]); +assert.deepEqual(trail, [ + path.resolve(root, 'resources/pushd/b/c'), + path.resolve(root, 'resources/pushd/b'), + path.resolve(root, 'resources/pushd/a'), + path.resolve(root, 'resources/pushd'), + root +]); + +trail = shell.pushd('-4'); +assert.equal(shell.error(), null); +assert.equal(process.cwd(), trail[0]); +assert.deepEqual(trail, [ + path.resolve(root, 'resources/pushd/b/c'), + path.resolve(root, 'resources/pushd/b'), + path.resolve(root, 'resources/pushd/a'), + path.resolve(root, 'resources/pushd'), + root +]); + +// Push without changing directory or resolving paths +reset(); trail = shell.pushd('-n', 'resources/pushd'); +assert.equal(shell.error(), null); +assert.equal(process.cwd(), trail[0]); +assert.deepEqual(trail, [ + root, + 'resources/pushd' +]); + +trail = shell.pushd('-n', 'resources/pushd/a'); +assert.equal(shell.error(), null); +assert.equal(process.cwd(), trail[0]); +assert.deepEqual(trail, [ + root, + 'resources/pushd/a', + 'resources/pushd' +]); + +// Push invalid directory +shell.pushd('does/not/exist'); +assert.equal(shell.error(), 'pushd: no such file or directory: ' + path.resolve('.', 'does/not/exist') + '\n'); +assert.equal(process.cwd(), trail[0]); + +// Push without arguments should swap top two directories when stack length is 2 +reset(); trail = shell.pushd('resources/pushd'); +assert.equal(shell.error(), null); +assert.equal(trail.length, 2); +assert.equal(path.relative(root, trail[0]), 'resources/pushd'); +assert.equal(trail[1], root); +assert.equal(process.cwd(), trail[0]); +trail = shell.pushd(); +assert.equal(shell.error(), null); +assert.equal(trail.length, 2); +assert.equal(trail[0], root); +assert.equal(path.relative(root, trail[1]), 'resources/pushd'); +assert.equal(process.cwd(), trail[0]); + +// Push without arguments should swap top two directories when stack length is > 2 +trail = shell.pushd('resources/pushd/a'); +assert.equal(shell.error(), null); +assert.equal(trail.length, 3); +assert.equal(path.relative(root, trail[0]), 'resources/pushd/a'); +assert.equal(trail[1], root); +assert.equal(path.relative(root, trail[2]), 'resources/pushd'); +assert.equal(process.cwd(), trail[0]); + +trail = shell.pushd(); +assert.equal(shell.error(), null); +assert.equal(trail.length, 3); +assert.equal(trail[0], root); +assert.equal(path.relative(root, trail[1]), 'resources/pushd/a'); +assert.equal(path.relative(root, trail[2]), 'resources/pushd'); +assert.equal(process.cwd(), trail[0]); + +// Push without arguments invalid when stack is empty +reset(); shell.pushd(); +assert.equal(shell.error(), 'pushd: no other directory\n'); + +shell.exit(123); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/pwd.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/pwd.js b/node_modules/shelljs/test/pwd.js new file mode 100644 index 0000000..d1f563f --- /dev/null +++ b/node_modules/shelljs/test/pwd.js @@ -0,0 +1,28 @@ +var shell = require('..'); + +var assert = require('assert'), + path = require('path'); + +shell.config.silent = true; + +function numLines(str) { + return typeof str === 'string' ? str.match(/\n/g).length : 0; +} + +shell.rm('-rf', 'tmp'); +shell.mkdir('tmp'); + +// +// Valids +// + +var _pwd = shell.pwd(); +assert.equal(shell.error(), null); +assert.equal(_pwd, path.resolve('.')); + +shell.cd('tmp'); +var _pwd = shell.pwd(); +assert.equal(shell.error(), null); +assert.equal(path.basename(_pwd), 'tmp'); + +shell.exit(123); http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/a.txt ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/a.txt b/node_modules/shelljs/test/resources/a.txt new file mode 100644 index 0000000..356ce49 --- /dev/null +++ b/node_modules/shelljs/test/resources/a.txt @@ -0,0 +1,11 @@ +This is line one +This is line two + +This is line four +. +. +More content here +. +. + +This is line eleven http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/chmod/a/b/c/.npmignore ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/chmod/a/b/c/.npmignore b/node_modules/shelljs/test/resources/chmod/a/b/c/.npmignore new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/chmod/b/a/b/.npmignore ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/chmod/b/a/b/.npmignore b/node_modules/shelljs/test/resources/chmod/b/a/b/.npmignore new file mode 100755 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/chmod/c/a/b/.npmignore ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/chmod/c/a/b/.npmignore b/node_modules/shelljs/test/resources/chmod/c/a/b/.npmignore new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/chmod/file1 ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/chmod/file1 b/node_modules/shelljs/test/resources/chmod/file1 new file mode 100644 index 0000000..db3f9ca --- /dev/null +++ b/node_modules/shelljs/test/resources/chmod/file1 @@ -0,0 +1,2 @@ +this is test file 1 +default state should be 0644 (rw-r--r--) http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/cp/a ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/cp/a b/node_modules/shelljs/test/resources/cp/a new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/node_modules/shelljs/test/resources/cp/a @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/cp/b ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/cp/b b/node_modules/shelljs/test/resources/cp/b new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/node_modules/shelljs/test/resources/cp/b @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/cp/dir_a/z ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/cp/dir_a/z b/node_modules/shelljs/test/resources/cp/dir_a/z new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/node_modules/shelljs/test/resources/cp/dir_a/z @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/cp/dir_b/dir_b_a/dir_b_a_a/z ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/cp/dir_b/dir_b_a/dir_b_a_a/z b/node_modules/shelljs/test/resources/cp/dir_b/dir_b_a/dir_b_a_a/z new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/node_modules/shelljs/test/resources/cp/dir_b/dir_b_a/dir_b_a_a/z @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/external/node_script.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/external/node_script.js b/node_modules/shelljs/test/resources/external/node_script.js new file mode 100755 index 0000000..3b2d24a --- /dev/null +++ b/node_modules/shelljs/test/resources/external/node_script.js @@ -0,0 +1,2 @@ +console.log('node_script_1234'); + http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/file1 ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/file1 b/node_modules/shelljs/test/resources/file1 new file mode 100644 index 0000000..f079749 --- /dev/null +++ b/node_modules/shelljs/test/resources/file1 @@ -0,0 +1 @@ +test1 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/file1.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/file1.js b/node_modules/shelljs/test/resources/file1.js new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/node_modules/shelljs/test/resources/file1.js @@ -0,0 +1 @@ +test http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/file1.txt ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/file1.txt b/node_modules/shelljs/test/resources/file1.txt new file mode 100644 index 0000000..a5bce3f --- /dev/null +++ b/node_modules/shelljs/test/resources/file1.txt @@ -0,0 +1 @@ +test1 http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/file2 ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/file2 b/node_modules/shelljs/test/resources/file2 new file mode 100644 index 0000000..d606037 --- /dev/null +++ b/node_modules/shelljs/test/resources/file2 @@ -0,0 +1 @@ +test2 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/file2.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/file2.js b/node_modules/shelljs/test/resources/file2.js new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/node_modules/shelljs/test/resources/file2.js @@ -0,0 +1 @@ +test http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/file2.txt ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/file2.txt b/node_modules/shelljs/test/resources/file2.txt new file mode 100644 index 0000000..180cf83 --- /dev/null +++ b/node_modules/shelljs/test/resources/file2.txt @@ -0,0 +1 @@ +test2 http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/find/.hidden ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/find/.hidden b/node_modules/shelljs/test/resources/find/.hidden new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/node_modules/shelljs/test/resources/find/.hidden @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/find/a ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/find/a b/node_modules/shelljs/test/resources/find/a new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/node_modules/shelljs/test/resources/find/a @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/find/b ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/find/b b/node_modules/shelljs/test/resources/find/b new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/node_modules/shelljs/test/resources/find/b @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/find/dir1/a_dir1 ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/find/dir1/a_dir1 b/node_modules/shelljs/test/resources/find/dir1/a_dir1 new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/node_modules/shelljs/test/resources/find/dir1/a_dir1 @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/find/dir1/dir11/a_dir11 ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/find/dir1/dir11/a_dir11 b/node_modules/shelljs/test/resources/find/dir1/dir11/a_dir11 new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/node_modules/shelljs/test/resources/find/dir1/dir11/a_dir11 @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/find/dir2/a_dir1 ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/find/dir2/a_dir1 b/node_modules/shelljs/test/resources/find/dir2/a_dir1 new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/node_modules/shelljs/test/resources/find/dir2/a_dir1 @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/issue44/main.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/issue44/main.js b/node_modules/shelljs/test/resources/issue44/main.js new file mode 100644 index 0000000..d800886 --- /dev/null +++ b/node_modules/shelljs/test/resources/issue44/main.js @@ -0,0 +1 @@ +123 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/ls/.hidden_dir/nada ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/ls/.hidden_dir/nada b/node_modules/shelljs/test/resources/ls/.hidden_dir/nada new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/node_modules/shelljs/test/resources/ls/.hidden_dir/nada @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/ls/.hidden_file ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/ls/.hidden_file b/node_modules/shelljs/test/resources/ls/.hidden_file new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/node_modules/shelljs/test/resources/ls/.hidden_file @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/ls/a_dir/.hidden_dir/nada ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/ls/a_dir/.hidden_dir/nada b/node_modules/shelljs/test/resources/ls/a_dir/.hidden_dir/nada new file mode 100644 index 0000000..5fedf57 --- /dev/null +++ b/node_modules/shelljs/test/resources/ls/a_dir/.hidden_dir/nada @@ -0,0 +1 @@ +nada \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/ls/a_dir/b_dir/z ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/ls/a_dir/b_dir/z b/node_modules/shelljs/test/resources/ls/a_dir/b_dir/z new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/node_modules/shelljs/test/resources/ls/a_dir/b_dir/z @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/ls/a_dir/nada ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/ls/a_dir/nada b/node_modules/shelljs/test/resources/ls/a_dir/nada new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/node_modules/shelljs/test/resources/ls/a_dir/nada @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/ls/file1 ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/ls/file1 b/node_modules/shelljs/test/resources/ls/file1 new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/node_modules/shelljs/test/resources/ls/file1 @@ -0,0 +1 @@ +test http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/ls/file1.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/ls/file1.js b/node_modules/shelljs/test/resources/ls/file1.js new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/node_modules/shelljs/test/resources/ls/file1.js @@ -0,0 +1 @@ +test http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/ls/file2 ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/ls/file2 b/node_modules/shelljs/test/resources/ls/file2 new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/node_modules/shelljs/test/resources/ls/file2 @@ -0,0 +1 @@ +test http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/ls/file2.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/ls/file2.js b/node_modules/shelljs/test/resources/ls/file2.js new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/node_modules/shelljs/test/resources/ls/file2.js @@ -0,0 +1 @@ +test http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/ls/filename(with)[chars$]^that.must+be-escaped ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/ls/filename(with)[chars$]^that.must+be-escaped b/node_modules/shelljs/test/resources/ls/filename(with)[chars$]^that.must+be-escaped new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/node_modules/shelljs/test/resources/ls/filename(with)[chars$]^that.must+be-escaped @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/pushd/a/dummy ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/pushd/a/dummy b/node_modules/shelljs/test/resources/pushd/a/dummy new file mode 100644 index 0000000..72e12a9 --- /dev/null +++ b/node_modules/shelljs/test/resources/pushd/a/dummy @@ -0,0 +1 @@ +meh \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/resources/pushd/b/c/dummy ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/resources/pushd/b/c/dummy b/node_modules/shelljs/test/resources/pushd/b/c/dummy new file mode 100644 index 0000000..72e12a9 --- /dev/null +++ b/node_modules/shelljs/test/resources/pushd/b/c/dummy @@ -0,0 +1 @@ +meh \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/rm.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/rm.js b/node_modules/shelljs/test/rm.js new file mode 100644 index 0000000..61182a1 --- /dev/null +++ b/node_modules/shelljs/test/rm.js @@ -0,0 +1,183 @@ +var shell = require('..'); + +var assert = require('assert'), + path = require('path'), + fs = require('fs'); + +// Node shims for < v0.7 +fs.existsSync = fs.existsSync || path.existsSync; + +shell.config.silent = true; + +shell.rm('-rf', 'tmp'); +shell.mkdir('tmp'); + +// +// Invalids +// + +shell.rm(); +assert.ok(shell.error()); + +shell.rm('asdfasdf'); // file does not exist +assert.ok(shell.error()); + +shell.rm('-f'); // no file +assert.ok(shell.error()); + +shell.rm('-@', 'resources/file1'); // invalid option +assert.ok(shell.error()); +assert.equal(fs.existsSync('resources/file1'), true); + +// +// Valids +// + +// file does not exist, but -f specified +shell.rm('-f', 'asdfasdf'); +assert.equal(shell.error(), null); + +// simple rm +shell.cp('-f', 'resources/file1', 'tmp/file1'); +assert.equal(fs.existsSync('tmp/file1'), true); +shell.rm('tmp/file1'); +assert.equal(shell.error(), null); +assert.equal(fs.existsSync('tmp/file1'), false); + +// recursive dir removal - small-caps '-r' +shell.mkdir('-p', 'tmp/a/b/c'); +assert.equal(fs.existsSync('tmp/a/b/c'), true); +shell.rm('-rf', 'tmp/a'); +assert.equal(shell.error(), null); +assert.equal(fs.existsSync('tmp/a'), false); + +// recursive dir removal - capital '-R' +shell.mkdir('-p', 'tmp/a/b/c'); +assert.equal(fs.existsSync('tmp/a/b/c'), true); +shell.rm('-Rf', 'tmp/a'); +assert.equal(shell.error(), null); +assert.equal(fs.existsSync('tmp/a'), false); + +// recursive dir removal - absolute path +shell.mkdir('-p', 'tmp/a/b/c'); +assert.equal(fs.existsSync('tmp/a/b/c'), true); +shell.rm('-Rf', path.resolve('./tmp/a')); +assert.equal(shell.error(), null); +assert.equal(fs.existsSync('tmp/a'), false); + +// wildcard +shell.cp('-f', 'resources/file*', 'tmp'); +assert.equal(shell.error(), null); +assert.equal(fs.existsSync('tmp/file1'), true); +assert.equal(fs.existsSync('tmp/file2'), true); +assert.equal(fs.existsSync('tmp/file1.js'), true); +assert.equal(fs.existsSync('tmp/file2.js'), true); +shell.rm('tmp/file*'); +assert.equal(shell.error(), null); +assert.equal(fs.existsSync('tmp/file1'), false); +assert.equal(fs.existsSync('tmp/file2'), false); +assert.equal(fs.existsSync('tmp/file1.js'), false); +assert.equal(fs.existsSync('tmp/file2.js'), false); + +// recursive dir removal +shell.mkdir('-p', 'tmp/a/b/c'); +shell.mkdir('-p', 'tmp/b'); +shell.mkdir('-p', 'tmp/c'); +shell.mkdir('-p', 'tmp/.hidden'); +assert.equal(fs.existsSync('tmp/a/b/c'), true); +assert.equal(fs.existsSync('tmp/b'), true); +assert.equal(fs.existsSync('tmp/c'), true); +assert.equal(fs.existsSync('tmp/.hidden'), true); +shell.rm('-rf', 'tmp/*'); +assert.equal(shell.error(), null); +var contents = fs.readdirSync('tmp'); +assert.equal(contents.length, 1); +assert.equal(contents[0], '.hidden'); // shouldn't remove hiddden if no .* given + +// recursive dir removal +shell.mkdir('-p', 'tmp/a/b/c'); +shell.mkdir('-p', 'tmp/b'); +shell.mkdir('-p', 'tmp/c'); +shell.mkdir('-p', 'tmp/.hidden'); +assert.equal(fs.existsSync('tmp/a/b/c'), true); +assert.equal(fs.existsSync('tmp/b'), true); +assert.equal(fs.existsSync('tmp/c'), true); +assert.equal(fs.existsSync('tmp/.hidden'), true); +shell.rm('-rf', 'tmp/*', 'tmp/.*'); +assert.equal(shell.error(), null); +var contents = fs.readdirSync('tmp'); +assert.equal(contents.length, 0); + +// recursive dir removal - array-syntax +shell.mkdir('-p', 'tmp/a/b/c'); +shell.mkdir('-p', 'tmp/b'); +shell.mkdir('-p', 'tmp/c'); +shell.mkdir('-p', 'tmp/.hidden'); +assert.equal(fs.existsSync('tmp/a/b/c'), true); +assert.equal(fs.existsSync('tmp/b'), true); +assert.equal(fs.existsSync('tmp/c'), true); +assert.equal(fs.existsSync('tmp/.hidden'), true); +shell.rm('-rf', ['tmp/*', 'tmp/.*']); +assert.equal(shell.error(), null); +var contents = fs.readdirSync('tmp'); +assert.equal(contents.length, 0); + +// removal of a read-only file (unforced) +shell.mkdir('-p', 'tmp/readonly'); +'asdf'.to('tmp/readonly/file1'); +fs.chmodSync('tmp/readonly/file1', '0444'); // -r--r--r-- +shell.rm('tmp/readonly/file1'); +assert.equal(fs.existsSync('tmp/readonly/file1'), true); // bash's rm always asks before removing read-only files + // here we just assume "no" + +// removal of a read-only file (forced) +shell.mkdir('-p', 'tmp/readonly'); +'asdf'.to('tmp/readonly/file2'); +fs.chmodSync('tmp/readonly/file2', '0444'); // -r--r--r-- +shell.rm('-f', 'tmp/readonly/file2'); +assert.equal(fs.existsSync('tmp/readonly/file2'), false); + +// removal of a tree containing read-only files (unforced) +shell.mkdir('-p', 'tmp/tree2'); +'asdf'.to('tmp/tree2/file1'); +'asdf'.to('tmp/tree2/file2'); +fs.chmodSync('tmp/tree2/file1', '0444'); // -r--r--r-- +shell.rm('-r', 'tmp/tree2'); +assert.equal(fs.existsSync('tmp/tree2/file1'), true); +assert.equal(fs.existsSync('tmp/tree2/file2'), false); + +// removal of a tree containing read-only files (forced) +shell.mkdir('-p', 'tmp/tree'); +'asdf'.to('tmp/tree/file1'); +'asdf'.to('tmp/tree/file2'); +fs.chmodSync('tmp/tree/file1', '0444'); // -r--r--r-- +shell.rm('-rf', 'tmp/tree'); +assert.equal(fs.existsSync('tmp/tree'), false); + +// removal of a sub-tree containing read-only and hidden files - rm('dir/*') +shell.mkdir('-p', 'tmp/tree3'); +shell.mkdir('-p', 'tmp/tree3/subtree'); +shell.mkdir('-p', 'tmp/tree3/.hidden'); +'asdf'.to('tmp/tree3/subtree/file'); +'asdf'.to('tmp/tree3/.hidden/file'); +'asdf'.to('tmp/tree3/file'); +fs.chmodSync('tmp/tree3/file', '0444'); // -r--r--r-- +fs.chmodSync('tmp/tree3/subtree/file', '0444'); // -r--r--r-- +fs.chmodSync('tmp/tree3/.hidden/file', '0444'); // -r--r--r-- +shell.rm('-rf', 'tmp/tree3/*', 'tmp/tree3/.*'); // erase dir contents +assert.equal(shell.ls('tmp/tree3').length, 0); + +// removal of a sub-tree containing read-only and hidden files - rm('dir') +shell.mkdir('-p', 'tmp/tree4'); +shell.mkdir('-p', 'tmp/tree4/subtree'); +shell.mkdir('-p', 'tmp/tree4/.hidden'); +'asdf'.to('tmp/tree4/subtree/file'); +'asdf'.to('tmp/tree4/.hidden/file'); +'asdf'.to('tmp/tree4/file'); +fs.chmodSync('tmp/tree4/file', '0444'); // -r--r--r-- +fs.chmodSync('tmp/tree4/subtree/file', '0444'); // -r--r--r-- +fs.chmodSync('tmp/tree4/.hidden/file', '0444'); // -r--r--r-- +shell.rm('-rf', 'tmp/tree4'); // erase dir contents +assert.equal(fs.existsSync('tmp/tree4'), false); + +shell.exit(123); http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/sed.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/sed.js b/node_modules/shelljs/test/sed.js new file mode 100644 index 0000000..d3d66b1 --- /dev/null +++ b/node_modules/shelljs/test/sed.js @@ -0,0 +1,58 @@ +var shell = require('..'); + +var assert = require('assert'), + path = require('path'), + fs = require('fs'); + +// Node shims for < v0.7 +fs.existsSync = fs.existsSync || path.existsSync; + +shell.config.silent = true; + +function numLines(str) { + return typeof str === 'string' ? str.match(/\n/g).length : 0; +} + +shell.rm('-rf', 'tmp'); +shell.mkdir('tmp'); + +// +// Invalids +// + +shell.sed(); +assert.ok(shell.error()); + +shell.sed(/asdf/g); // too few args +assert.ok(shell.error()); + +shell.sed(/asdf/g, 'nada'); // too few args +assert.ok(shell.error()); + +assert.equal(fs.existsSync('/asdfasdf'), false); // sanity check +shell.sed(/asdf/g, 'nada', '/asdfasdf'); // no such file +assert.ok(shell.error()); + +// +// Valids +// + +shell.cp('-f', 'resources/file1', 'tmp/file1'); +var result = shell.sed('test1', 'hello', 'tmp/file1'); // search string +assert.equal(shell.error(), null); +assert.equal(result, 'hello'); + +var result = shell.sed(/test1/, 'hello', 'tmp/file1'); // search regex +assert.equal(shell.error(), null); +assert.equal(result, 'hello'); + +var result = shell.sed(/test1/, 1234, 'tmp/file1'); // numeric replacement +assert.equal(shell.error(), null); +assert.equal(result, '1234'); + +var result = shell.sed('-i', /test1/, 'hello', 'tmp/file1'); +assert.equal(shell.error(), null); +assert.equal(result, 'hello'); +assert.equal(shell.cat('tmp/file1'), 'hello'); + +shell.exit(123); http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/tempdir.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/tempdir.js b/node_modules/shelljs/test/tempdir.js new file mode 100644 index 0000000..704ca56 --- /dev/null +++ b/node_modules/shelljs/test/tempdir.js @@ -0,0 +1,27 @@ +var shell = require('..'); + +var assert = require('assert'), + path = require('path'), + fs = require('fs'); + +// Node shims for < v0.7 +fs.existsSync = fs.existsSync || path.existsSync; + +shell.config.silent = true; + +function numLines(str) { + return typeof str === 'string' ? str.match(/\n/g).length : 0; +} + +shell.rm('-rf', 'tmp'); +shell.mkdir('tmp'); + +// +// Valids +// + +var tmp = shell.tempdir(); +assert.equal(shell.error(), null); +assert.equal(fs.existsSync(tmp), true); + +shell.exit(123); http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/test.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/test.js b/node_modules/shelljs/test/test.js new file mode 100644 index 0000000..a824edb --- /dev/null +++ b/node_modules/shelljs/test/test.js @@ -0,0 +1,91 @@ +var shell = require('..'); + +var assert = require('assert'), + path = require('path'), + fs = require('fs'); + +// Node shims for < v0.7 +fs.existsSync = fs.existsSync || path.existsSync; + +shell.config.silent = true; + +shell.rm('-rf', 'tmp'); +shell.mkdir('tmp'); + +// +// Invalids +// + +var result = shell.test(); // no expression given +assert.ok(shell.error()); + +var result = shell.test('asdf'); // bad expression +assert.ok(shell.error()); + +var result = shell.test('f', 'resources/file1'); // bad expression +assert.ok(shell.error()); + +var result = shell.test('-f'); // no file +assert.ok(shell.error()); + +// +// Valids +// + +//exists +var result = shell.test('-e', 'resources/file1'); +assert.equal(shell.error(), null); +assert.equal(result, true);//true + +var result = shell.test('-e', 'resources/404'); +assert.equal(shell.error(), null); +assert.equal(result, false); + +//directory +var result = shell.test('-d', 'resources'); +assert.equal(shell.error(), null); +assert.equal(result, true);//true + +var result = shell.test('-f', 'resources'); +assert.equal(shell.error(), null); +assert.equal(result, false); + +var result = shell.test('-L', 'resources'); +assert.equal(shell.error(), null); +assert.equal(result, false); + +//file +var result = shell.test('-d', 'resources/file1'); +assert.equal(shell.error(), null); +assert.equal(result, false); + +var result = shell.test('-f', 'resources/file1'); +assert.equal(shell.error(), null); +assert.equal(result, true);//true + +var result = shell.test('-L', 'resources/file1'); +assert.equal(shell.error(), null); +assert.equal(result, false); + +//link +var result = shell.test('-d', 'resources/link'); +assert.equal(shell.error(), null); +assert.equal(result, false); + +var result = shell.test('-f', 'resources/link'); +assert.equal(shell.error(), null); +assert.equal(result, true);//true + +var result = shell.test('-L', 'resources/link'); +assert.equal(shell.error(), null); +assert.equal(result, true);//true + +var result = shell.test('-L', 'resources/badlink'); +assert.equal(shell.error(), null); +assert.equal(result, true);//true + +var result = shell.test('-L', 'resources/404'); +assert.equal(shell.error(), null); +assert.equal(result, false);//false + +shell.exit(123); http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/to.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/to.js b/node_modules/shelljs/test/to.js new file mode 100644 index 0000000..2e1253d --- /dev/null +++ b/node_modules/shelljs/test/to.js @@ -0,0 +1,39 @@ +var shell = require('..'); + +var assert = require('assert'), + path = require('path'), + fs = require('fs'); + +// Node shims for < v0.7 +fs.existsSync = fs.existsSync || path.existsSync; + +shell.config.silent = true; + +function numLines(str) { + return typeof str === 'string' ? str.match(/\n/g).length : 0; +} + +shell.rm('-rf', 'tmp'); +shell.mkdir('tmp'); + +// +// Invalids +// + +'hello world'.to(); +assert.ok(shell.error()); + +assert.equal(fs.existsSync('/asdfasdf'), false); // sanity check +'hello world'.to('/asdfasdf/file'); +assert.ok(shell.error()); + +// +// Valids +// + +'hello world'.to('tmp/to1'); +var result = shell.cat('tmp/to1'); +assert.equal(shell.error(), null); +assert.equal(result, 'hello world'); + +shell.exit(123); http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/node_modules/shelljs/test/which.js ---------------------------------------------------------------------- diff --git a/node_modules/shelljs/test/which.js b/node_modules/shelljs/test/which.js new file mode 100644 index 0000000..ac9a04d --- /dev/null +++ b/node_modules/shelljs/test/which.js @@ -0,0 +1,38 @@ +var shell = require('..'); + +var assert = require('assert'), + path = require('path'), + fs = require('fs'); + +// Node shims for < v0.7 +fs.existsSync = fs.existsSync || path.existsSync; + +shell.config.silent = true; + +function numLines(str) { + return typeof str === 'string' ? str.match(/\n/g).length : 0; +} + +shell.rm('-rf', 'tmp'); +shell.mkdir('tmp'); + +// +// Invalids +// + +shell.which(); +assert.ok(shell.error()); + +var result = shell.which('asdfasdfasdfasdfasdf'); // what are the odds... +assert.equal(shell.error(), null); +assert.equal(result, null); + +// +// Valids +// + +var result = shell.which('node'); +assert.equal(shell.error(), null); +assert.equal(fs.existsSync(result), true); + +shell.exit(123); http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/926681b8/package.json ---------------------------------------------------------------------- diff --git a/package.json b/package.json index a047d36..8820d05 100644 --- a/package.json +++ b/package.json @@ -14,9 +14,12 @@ ], "dependencies": { "shelljs": "^0.1.4", - "adm-zip": "0.4.4", - "open": "0.0.x" + "adm-zip": "0.4.4" }, + "bundledDependencies": [ + "shelljs", + "adm-zip" + ], "author": "Apache Software Foundation", "contributors": [ {"name": "Steve Gill", "email": "stev...@adobe.com"},