http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/echo.js ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/echo.js b/wp8/node_modules/shelljs/test/echo.js new file mode 100644 index 0000000..82faa51 --- /dev/null +++ b/wp8/node_modules/shelljs/test/echo.js @@ -0,0 +1,50 @@ +var shell = require('..'); + +var assert = require('assert'), + path = require('path'), + fs = require('fs'), + child = require('child_process'); + +// 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 +// + + +// From here on we use child.exec() to intercept the stdout + + +// simple test with defaults +shell.mkdir('-p', 'tmp'); +var file = 'tmp/tempscript'+Math.random()+'.js', + script = 'require(\'../../global.js\'); echo("-asdf", "111");'; // test '-' bug (see issue #20) +script.to(file); +child.exec('node '+file, function(err, stdout, stderr) { + assert.ok(stdout === '-asdf 111\n' || stdout === '-asdf 111\nundefined\n'); // 'undefined' for v0.4 + + // simple test with silent(true) + shell.mkdir('-p', 'tmp'); + var file = 'tmp/tempscript'+Math.random()+'.js', + script = 'require(\'../../global.js\'); config.silent=true; echo(555);'; + script.to(file); + child.exec('node '+file, function(err, stdout, stderr) { + assert.ok(stdout === '555\n' || stdout === '555\nundefined\n'); // 'undefined' for v0.4 + + theEnd(); + }); +}); + +function theEnd() { + shell.exit(123); +}
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/env.js ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/env.js b/wp8/node_modules/shelljs/test/env.js new file mode 100644 index 0000000..0e041d6 --- /dev/null +++ b/wp8/node_modules/shelljs/test/env.js @@ -0,0 +1,19 @@ +var shell = require('..'); + +var assert = require('assert'); + +shell.config.silent = true; + +shell.rm('-rf', 'tmp'); +shell.mkdir('tmp'); + +// +// Valids +// + +assert.equal(shell.env['PATH'], process.env['PATH']); + +shell.env['SHELLJS_TEST'] = 'hello world'; +assert.equal(shell.env['SHELLJS_TEST'], process.env['SHELLJS_TEST']); + +shell.exit(123); http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/exec.js ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/exec.js b/wp8/node_modules/shelljs/test/exec.js new file mode 100644 index 0000000..e721808 --- /dev/null +++ b/wp8/node_modules/shelljs/test/exec.js @@ -0,0 +1,109 @@ +var shell = require('..'); + +var assert = require('assert'), + path = require('path'), + fs = require('fs'), + util = require('util'), + child = require('child_process'); + +shell.config.silent = true; + +function numLines(str) { + return typeof str === 'string' ? str.match(/\n/g).length : 0; +} + +// +// Invalids +// + +shell.exec(); +assert.ok(shell.error()); + +var result = shell.exec('asdfasdf'); // could not find command +assert.ok(result.code > 0); + + +// +// Valids +// + +// +// sync +// + +// check if stdout goes to output +var result = shell.exec('node -e \"console.log(1234);\"'); +assert.equal(shell.error(), null); +assert.equal(result.code, 0); +assert.ok(result.output === '1234\n' || result.output === '1234\nundefined\n'); // 'undefined' for v0.4 + +// check if stderr goes to output +var result = shell.exec('node -e \"console.error(1234);\"'); +assert.equal(shell.error(), null); +assert.equal(result.code, 0); +assert.ok(result.output === '1234\n' || result.output === '1234\nundefined\n'); // 'undefined' for v0.4 + +// check if stdout + stderr go to output +var result = shell.exec('node -e \"console.error(1234); console.log(666);\"'); +assert.equal(shell.error(), null); +assert.equal(result.code, 0); +assert.ok(result.output === '1234\n666\n' || result.output === '1234\n666\nundefined\n'); // 'undefined' for v0.4 + +// check exit code +var result = shell.exec('node -e \"process.exit(12);\"'); +assert.equal(shell.error(), null); +assert.equal(result.code, 12); + +// interaction with cd +shell.cd('resources/external'); +var result = shell.exec('node node_script.js'); +assert.equal(shell.error(), null); +assert.equal(result.code, 0); +assert.equal(result.output, 'node_script_1234\n'); +shell.cd('../..'); + +// check quotes escaping +var result = shell.exec( util.format('node -e "console.log(%s);"', "\\\"\\'+\\'_\\'+\\'\\\"") ); +assert.equal(shell.error(), null); +assert.equal(result.code, 0); +assert.equal(result.output, "'+'_'+'\n"); + +// +// async +// + +// no callback +var c = shell.exec('node -e \"console.log(1234)\"', {async:true}); +assert.equal(shell.error(), null); +assert.ok('stdout' in c, 'async exec returns child process object'); + +// +// callback as 2nd argument +// +shell.exec('node -e \"console.log(5678);\"', function(code, output) { + assert.equal(code, 0); + assert.ok(output === '5678\n' || output === '5678\nundefined\n'); // 'undefined' for v0.4 + + // + // callback as 3rd argument + // + shell.exec('node -e \"console.log(5566);\"', {async:true}, function(code, output) { + assert.equal(code, 0); + assert.ok(output === '5566\n' || output === '5566\nundefined\n'); // 'undefined' for v0.4 + + // + // callback as 3rd argument (slient:true) + // + shell.exec('node -e \"console.log(5678);\"', {silent:true}, function(code, output) { + assert.equal(code, 0); + assert.ok(output === '5678\n' || output === '5678\nundefined\n'); // 'undefined' for v0.4 + + shell.exit(123); + + }); + + }); + +}); + +assert.equal(shell.error(), null); http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/find.js ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/find.js b/wp8/node_modules/shelljs/test/find.js new file mode 100644 index 0000000..d375f86 --- /dev/null +++ b/wp8/node_modules/shelljs/test/find.js @@ -0,0 +1,56 @@ +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.find(); // no paths given +assert.ok(shell.error()); + +// +// Valids +// + +// current path +shell.cd('resources/find'); +var result = shell.find('.'); +assert.equal(shell.error(), null); +assert.equal(result.indexOf('.hidden') > -1, true); +assert.equal(result.indexOf('dir1/dir11/a_dir11') > -1, true); +assert.equal(result.length, 11); +shell.cd('../..'); + +// simple path +var result = shell.find('resources/find'); +assert.equal(shell.error(), null); +assert.equal(result.indexOf('resources/find/.hidden') > -1, true); +assert.equal(result.indexOf('resources/find/dir1/dir11/a_dir11') > -1, true); +assert.equal(result.length, 11); + +// multiple paths - comma +var result = shell.find('resources/find/dir1', 'resources/find/dir2'); +assert.equal(shell.error(), null); +assert.equal(result.indexOf('resources/find/dir1/dir11/a_dir11') > -1, true); +assert.equal(result.indexOf('resources/find/dir2/a_dir1') > -1, true); +assert.equal(result.length, 6); + +// multiple paths - array +var result = shell.find(['resources/find/dir1', 'resources/find/dir2']); +assert.equal(shell.error(), null); +assert.equal(result.indexOf('resources/find/dir1/dir11/a_dir11') > -1, true); +assert.equal(result.indexOf('resources/find/dir2/a_dir1') > -1, true); +assert.equal(result.length, 6); + +shell.exit(123); http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/grep.js ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/grep.js b/wp8/node_modules/shelljs/test/grep.js new file mode 100644 index 0000000..71db982 --- /dev/null +++ b/wp8/node_modules/shelljs/test/grep.js @@ -0,0 +1,59 @@ +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.grep(); +assert.ok(shell.error()); + +shell.grep(/asdf/g); // too few args +assert.ok(shell.error()); + +assert.equal(fs.existsSync('/asdfasdf'), false); // sanity check +shell.grep(/asdf/g, '/asdfasdf'); // no such file +assert.ok(shell.error()); + +// +// Valids +// + +var result = shell.grep('line', 'resources/a.txt'); +assert.equal(shell.error(), null); +assert.equal(result.split('\n').length - 1, 4); + +var result = shell.grep('-v', 'line', 'resources/a.txt'); +assert.equal(shell.error(), null); +assert.equal(result.split('\n').length - 1, 8); + +var result = shell.grep('line one', 'resources/a.txt'); +assert.equal(shell.error(), null); +assert.equal(result, 'This is line one\n'); + +// multiple files +var result = shell.grep(/test/, 'resources/file1.txt', 'resources/file2.txt'); +assert.equal(shell.error(), null); +assert.equal(result, 'test1\ntest2\n'); + +// multiple files, array syntax +var result = shell.grep(/test/, ['resources/file1.txt', 'resources/file2.txt']); +assert.equal(shell.error(), null); +assert.equal(result, 'test1\ntest2\n'); + +shell.exit(123); http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/ls.js ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/ls.js b/wp8/node_modules/shelljs/test/ls.js new file mode 100644 index 0000000..5067b7d --- /dev/null +++ b/wp8/node_modules/shelljs/test/ls.js @@ -0,0 +1,202 @@ +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 +// + +assert.equal(fs.existsSync('/asdfasdf'), false); // sanity check +var result = shell.ls('/asdfasdf'); // no such file or dir +assert.ok(shell.error()); +assert.equal(result.length, 0); + +// +// Valids +// + +var result = shell.ls(); +assert.equal(shell.error(), null); + +var result = shell.ls('/'); +assert.equal(shell.error(), null); + +// no args +shell.cd('resources/ls'); +var result = shell.ls(); +assert.equal(shell.error(), null); +assert.equal(result.indexOf('file1') > -1, true); +assert.equal(result.indexOf('file2') > -1, true); +assert.equal(result.indexOf('file1.js') > -1, true); +assert.equal(result.indexOf('file2.js') > -1, true); +assert.equal(result.indexOf('filename(with)[chars$]^that.must+be-escaped') > -1, true); +assert.equal(result.indexOf('a_dir') > -1, true); +assert.equal(result.length, 6); +shell.cd('../..'); + +// simple arg +var result = shell.ls('resources/ls'); +assert.equal(shell.error(), null); +assert.equal(result.indexOf('file1') > -1, true); +assert.equal(result.indexOf('file2') > -1, true); +assert.equal(result.indexOf('file1.js') > -1, true); +assert.equal(result.indexOf('file2.js') > -1, true); +assert.equal(result.indexOf('filename(with)[chars$]^that.must+be-escaped') > -1, true); +assert.equal(result.indexOf('a_dir') > -1, true); +assert.equal(result.length, 6); + +// no args, 'all' option +shell.cd('resources/ls'); +var result = shell.ls('-A'); +assert.equal(shell.error(), null); +assert.equal(result.indexOf('file1') > -1, true); +assert.equal(result.indexOf('file2') > -1, true); +assert.equal(result.indexOf('file1.js') > -1, true); +assert.equal(result.indexOf('file2.js') > -1, true); +assert.equal(result.indexOf('filename(with)[chars$]^that.must+be-escaped') > -1, true); +assert.equal(result.indexOf('a_dir') > -1, true); +assert.equal(result.indexOf('.hidden_file') > -1, true); +assert.equal(result.indexOf('.hidden_dir') > -1, true); +assert.equal(result.length, 8); +shell.cd('../..'); + +// no args, 'all' option +shell.cd('resources/ls'); +var result = shell.ls('-a'); // (deprecated) backwards compatibility test +assert.equal(shell.error(), null); +assert.equal(result.indexOf('file1') > -1, true); +assert.equal(result.indexOf('file2') > -1, true); +assert.equal(result.indexOf('file1.js') > -1, true); +assert.equal(result.indexOf('file2.js') > -1, true); +assert.equal(result.indexOf('filename(with)[chars$]^that.must+be-escaped') > -1, true); +assert.equal(result.indexOf('a_dir') > -1, true); +assert.equal(result.indexOf('.hidden_file') > -1, true); +assert.equal(result.indexOf('.hidden_dir') > -1, true); +assert.equal(result.length, 8); +shell.cd('../..'); + +// wildcard, simple +var result = shell.ls('resources/ls/*'); +assert.equal(shell.error(), null); +assert.equal(result.indexOf('resources/ls/file1') > -1, true); +assert.equal(result.indexOf('resources/ls/file2') > -1, true); +assert.equal(result.indexOf('resources/ls/file1.js') > -1, true); +assert.equal(result.indexOf('resources/ls/file2.js') > -1, true); +assert.equal(result.indexOf('resources/ls/filename(with)[chars$]^that.must+be-escaped') > -1, true); +assert.equal(result.indexOf('resources/ls/a_dir') > -1, true); +assert.equal(result.length, 6); + +// wildcard, hidden only +var result = shell.ls('resources/ls/.*'); +assert.equal(shell.error(), null); +assert.equal(result.indexOf('resources/ls/.hidden_file') > -1, true); +assert.equal(result.indexOf('resources/ls/.hidden_dir') > -1, true); +assert.equal(result.length, 2); + +// wildcard, mid-file +var result = shell.ls('resources/ls/f*le*'); +assert.equal(shell.error(), null); +assert.equal(result.length, 5); +assert.equal(result.indexOf('resources/ls/file1') > -1, true); +assert.equal(result.indexOf('resources/ls/file2') > -1, true); +assert.equal(result.indexOf('resources/ls/file1.js') > -1, true); +assert.equal(result.indexOf('resources/ls/file2.js') > -1, true); +assert.equal(result.indexOf('resources/ls/filename(with)[chars$]^that.must+be-escaped') > -1, true); + +// wildcard, mid-file with dot (should escape dot for regex) +var result = shell.ls('resources/ls/f*le*.js'); +assert.equal(shell.error(), null); +assert.equal(result.length, 2); +assert.equal(result.indexOf('resources/ls/file1.js') > -1, true); +assert.equal(result.indexOf('resources/ls/file2.js') > -1, true); + +// wildcard, should not do partial matches +var result = shell.ls('resources/ls/*.j'); // shouldn't get .js +assert.equal(shell.error(), null); +assert.equal(result.length, 0); + +// wildcard, all files with extension +var result = shell.ls('resources/ls/*.*'); +assert.equal(shell.error(), null); +assert.equal(result.length, 3); +assert.equal(result.indexOf('resources/ls/file1.js') > -1, true); +assert.equal(result.indexOf('resources/ls/file2.js') > -1, true); +assert.equal(result.indexOf('resources/ls/filename(with)[chars$]^that.must+be-escaped') > -1, true); + +// wildcard, with additional path +var result = shell.ls('resources/ls/f*le*.js', 'resources/ls/a_dir'); +assert.equal(shell.error(), null); +assert.equal(result.length, 4); +assert.equal(result.indexOf('resources/ls/file1.js') > -1, true); +assert.equal(result.indexOf('resources/ls/file2.js') > -1, true); +assert.equal(result.indexOf('b_dir') > -1, true); // no wildcard == no path prefix +assert.equal(result.indexOf('nada') > -1, true); // no wildcard == no path prefix + +// wildcard for both paths +var result = shell.ls('resources/ls/f*le*.js', 'resources/ls/a_dir/*'); +assert.equal(shell.error(), null); +assert.equal(result.length, 4); +assert.equal(result.indexOf('resources/ls/file1.js') > -1, true); +assert.equal(result.indexOf('resources/ls/file2.js') > -1, true); +assert.equal(result.indexOf('resources/ls/a_dir/b_dir') > -1, true); +assert.equal(result.indexOf('resources/ls/a_dir/nada') > -1, true); + +// wildcard for both paths, array +var result = shell.ls(['resources/ls/f*le*.js', 'resources/ls/a_dir/*']); +assert.equal(shell.error(), null); +assert.equal(result.length, 4); +assert.equal(result.indexOf('resources/ls/file1.js') > -1, true); +assert.equal(result.indexOf('resources/ls/file2.js') > -1, true); +assert.equal(result.indexOf('resources/ls/a_dir/b_dir') > -1, true); +assert.equal(result.indexOf('resources/ls/a_dir/nada') > -1, true); + +// recursive, no path +shell.cd('resources/ls'); +var result = shell.ls('-R'); +assert.equal(shell.error(), null); +assert.equal(result.indexOf('a_dir') > -1, true); +assert.equal(result.indexOf('a_dir/b_dir') > -1, true); +assert.equal(result.indexOf('a_dir/b_dir/z') > -1, true); +assert.equal(result.length, 9); +shell.cd('../..'); + +// recusive, path given +var result = shell.ls('-R', 'resources/ls'); +assert.equal(shell.error(), null); +assert.equal(result.indexOf('a_dir') > -1, true); +assert.equal(result.indexOf('a_dir/b_dir') > -1, true); +assert.equal(result.indexOf('a_dir/b_dir/z') > -1, true); +assert.equal(result.length, 9); + +// recusive, path given - 'all' flag +var result = shell.ls('-RA', 'resources/ls'); +assert.equal(shell.error(), null); +assert.equal(result.indexOf('a_dir') > -1, true); +assert.equal(result.indexOf('a_dir/b_dir') > -1, true); +assert.equal(result.indexOf('a_dir/b_dir/z') > -1, true); +assert.equal(result.indexOf('a_dir/.hidden_dir/nada') > -1, true); +assert.equal(result.length, 14); + +// recursive, wildcard +var result = shell.ls('-R', 'resources/ls/*'); +assert.equal(shell.error(), null); +assert.equal(result.indexOf('resources/ls/a_dir') > -1, true); +assert.equal(result.indexOf('resources/ls/a_dir/b_dir') > -1, true); +assert.equal(result.indexOf('resources/ls/a_dir/b_dir/z') > -1, true); +assert.equal(result.length, 9); + +shell.exit(123); http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/make.js ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/make.js b/wp8/node_modules/shelljs/test/make.js new file mode 100644 index 0000000..3edbd8c --- /dev/null +++ b/wp8/node_modules/shelljs/test/make.js @@ -0,0 +1,20 @@ +var shell = require('..'), + child = require('child_process'), + assert = require('assert'); + +shell.mkdir('-p', 'tmp'); +var file = 'tmp/tempscript'+Math.random()+'.js', + script = 'require(\'../../make.js\');' + + 'target.all=function(){' + + ' echo("first"); '+ + ' cp("this_file_doesnt_exist", ".");' + + ' echo("second");' + + '}'; + +script.to(file); +child.exec('node '+file, function(err, stdout, stderr) { + assert.ok(stdout.match('first')); + assert.ok(!stdout.match('second')); // Make should die on errors, so this should never get echoed + + shell.exit(123); +}); http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/mkdir.js ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/mkdir.js b/wp8/node_modules/shelljs/test/mkdir.js new file mode 100644 index 0000000..1f93422 --- /dev/null +++ b/wp8/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-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/mv.js ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/mv.js b/wp8/node_modules/shelljs/test/mv.js new file mode 100644 index 0000000..89bca91 --- /dev/null +++ b/wp8/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-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/popd.js ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/popd.js b/wp8/node_modules/shelljs/test/popd.js new file mode 100644 index 0000000..fd79533 --- /dev/null +++ b/wp8/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-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/pushd.js ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/pushd.js b/wp8/node_modules/shelljs/test/pushd.js new file mode 100644 index 0000000..32089dc --- /dev/null +++ b/wp8/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-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/pwd.js ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/pwd.js b/wp8/node_modules/shelljs/test/pwd.js new file mode 100644 index 0000000..d1f563f --- /dev/null +++ b/wp8/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-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/a.txt ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/a.txt b/wp8/node_modules/shelljs/test/resources/a.txt new file mode 100644 index 0000000..356ce49 --- /dev/null +++ b/wp8/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-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/chmod/a/b/c/.npmignore ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/chmod/a/b/c/.npmignore b/wp8/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-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/chmod/b/a/b/.npmignore ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/chmod/b/a/b/.npmignore b/wp8/node_modules/shelljs/test/resources/chmod/b/a/b/.npmignore new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/chmod/c/a/b/.npmignore ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/chmod/c/a/b/.npmignore b/wp8/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-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/chmod/file1 ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/chmod/file1 b/wp8/node_modules/shelljs/test/resources/chmod/file1 new file mode 100644 index 0000000..db3f9ca --- /dev/null +++ b/wp8/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-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/cp/a ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/cp/a b/wp8/node_modules/shelljs/test/resources/cp/a new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/wp8/node_modules/shelljs/test/resources/cp/a @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/cp/b ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/cp/b b/wp8/node_modules/shelljs/test/resources/cp/b new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/wp8/node_modules/shelljs/test/resources/cp/b @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/cp/dir_a/z ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/cp/dir_a/z b/wp8/node_modules/shelljs/test/resources/cp/dir_a/z new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/wp8/node_modules/shelljs/test/resources/cp/dir_a/z @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/cp/dir_b/dir_b_a/dir_b_a_a/z ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/cp/dir_b/dir_b_a/dir_b_a_a/z b/wp8/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/wp8/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-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/external/node_script.js ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/external/node_script.js b/wp8/node_modules/shelljs/test/resources/external/node_script.js new file mode 100644 index 0000000..3b2d24a --- /dev/null +++ b/wp8/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-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/file1 ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/file1 b/wp8/node_modules/shelljs/test/resources/file1 new file mode 100644 index 0000000..f079749 --- /dev/null +++ b/wp8/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-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/file1.js ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/file1.js b/wp8/node_modules/shelljs/test/resources/file1.js new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/wp8/node_modules/shelljs/test/resources/file1.js @@ -0,0 +1 @@ +test http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/file1.txt ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/file1.txt b/wp8/node_modules/shelljs/test/resources/file1.txt new file mode 100644 index 0000000..a5bce3f --- /dev/null +++ b/wp8/node_modules/shelljs/test/resources/file1.txt @@ -0,0 +1 @@ +test1 http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/file2 ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/file2 b/wp8/node_modules/shelljs/test/resources/file2 new file mode 100644 index 0000000..d606037 --- /dev/null +++ b/wp8/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-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/file2.js ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/file2.js b/wp8/node_modules/shelljs/test/resources/file2.js new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/wp8/node_modules/shelljs/test/resources/file2.js @@ -0,0 +1 @@ +test http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/file2.txt ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/file2.txt b/wp8/node_modules/shelljs/test/resources/file2.txt new file mode 100644 index 0000000..180cf83 --- /dev/null +++ b/wp8/node_modules/shelljs/test/resources/file2.txt @@ -0,0 +1 @@ +test2 http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/find/.hidden ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/find/.hidden b/wp8/node_modules/shelljs/test/resources/find/.hidden new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/wp8/node_modules/shelljs/test/resources/find/.hidden @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/find/a ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/find/a b/wp8/node_modules/shelljs/test/resources/find/a new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/wp8/node_modules/shelljs/test/resources/find/a @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/find/b ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/find/b b/wp8/node_modules/shelljs/test/resources/find/b new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/wp8/node_modules/shelljs/test/resources/find/b @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/find/dir1/a_dir1 ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/find/dir1/a_dir1 b/wp8/node_modules/shelljs/test/resources/find/dir1/a_dir1 new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/wp8/node_modules/shelljs/test/resources/find/dir1/a_dir1 @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/find/dir1/dir11/a_dir11 ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/find/dir1/dir11/a_dir11 b/wp8/node_modules/shelljs/test/resources/find/dir1/dir11/a_dir11 new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/wp8/node_modules/shelljs/test/resources/find/dir1/dir11/a_dir11 @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/find/dir2/a_dir1 ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/find/dir2/a_dir1 b/wp8/node_modules/shelljs/test/resources/find/dir2/a_dir1 new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/wp8/node_modules/shelljs/test/resources/find/dir2/a_dir1 @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/issue44/main.js ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/issue44/main.js b/wp8/node_modules/shelljs/test/resources/issue44/main.js new file mode 100644 index 0000000..d800886 --- /dev/null +++ b/wp8/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-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/ls/.hidden_dir/nada ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/ls/.hidden_dir/nada b/wp8/node_modules/shelljs/test/resources/ls/.hidden_dir/nada new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/wp8/node_modules/shelljs/test/resources/ls/.hidden_dir/nada @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/ls/.hidden_file ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/ls/.hidden_file b/wp8/node_modules/shelljs/test/resources/ls/.hidden_file new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/wp8/node_modules/shelljs/test/resources/ls/.hidden_file @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/ls/a_dir/.hidden_dir/nada ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/ls/a_dir/.hidden_dir/nada b/wp8/node_modules/shelljs/test/resources/ls/a_dir/.hidden_dir/nada new file mode 100644 index 0000000..5fedf57 --- /dev/null +++ b/wp8/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-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/ls/a_dir/b_dir/z ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/ls/a_dir/b_dir/z b/wp8/node_modules/shelljs/test/resources/ls/a_dir/b_dir/z new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/wp8/node_modules/shelljs/test/resources/ls/a_dir/b_dir/z @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/ls/a_dir/nada ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/ls/a_dir/nada b/wp8/node_modules/shelljs/test/resources/ls/a_dir/nada new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/wp8/node_modules/shelljs/test/resources/ls/a_dir/nada @@ -0,0 +1 @@ +asdf http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/ls/file1 ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/ls/file1 b/wp8/node_modules/shelljs/test/resources/ls/file1 new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/wp8/node_modules/shelljs/test/resources/ls/file1 @@ -0,0 +1 @@ +test http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/ls/file1.js ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/ls/file1.js b/wp8/node_modules/shelljs/test/resources/ls/file1.js new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/wp8/node_modules/shelljs/test/resources/ls/file1.js @@ -0,0 +1 @@ +test http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/ls/file2 ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/ls/file2 b/wp8/node_modules/shelljs/test/resources/ls/file2 new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/wp8/node_modules/shelljs/test/resources/ls/file2 @@ -0,0 +1 @@ +test http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/ls/file2.js ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/ls/file2.js b/wp8/node_modules/shelljs/test/resources/ls/file2.js new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/wp8/node_modules/shelljs/test/resources/ls/file2.js @@ -0,0 +1 @@ +test http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/ls/filename(with)[chars$]^that.must+be-escaped ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/ls/filename(with)[chars$]^that.must+be-escaped b/wp8/node_modules/shelljs/test/resources/ls/filename(with)[chars$]^that.must+be-escaped new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/wp8/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-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/pushd/a/dummy ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/pushd/a/dummy b/wp8/node_modules/shelljs/test/resources/pushd/a/dummy new file mode 100644 index 0000000..72e12a9 --- /dev/null +++ b/wp8/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-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/resources/pushd/b/c/dummy ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/resources/pushd/b/c/dummy b/wp8/node_modules/shelljs/test/resources/pushd/b/c/dummy new file mode 100644 index 0000000..72e12a9 --- /dev/null +++ b/wp8/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-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/rm.js ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/rm.js b/wp8/node_modules/shelljs/test/rm.js new file mode 100644 index 0000000..61182a1 --- /dev/null +++ b/wp8/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-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/sed.js ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/sed.js b/wp8/node_modules/shelljs/test/sed.js new file mode 100644 index 0000000..d3d66b1 --- /dev/null +++ b/wp8/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-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/tempdir.js ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/tempdir.js b/wp8/node_modules/shelljs/test/tempdir.js new file mode 100644 index 0000000..704ca56 --- /dev/null +++ b/wp8/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-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/test.js ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/test.js b/wp8/node_modules/shelljs/test/test.js new file mode 100644 index 0000000..a824edb --- /dev/null +++ b/wp8/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-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/to.js ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/to.js b/wp8/node_modules/shelljs/test/to.js new file mode 100644 index 0000000..2e1253d --- /dev/null +++ b/wp8/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-wp8/blob/c2c2e564/wp8/node_modules/shelljs/test/which.js ---------------------------------------------------------------------- diff --git a/wp8/node_modules/shelljs/test/which.js b/wp8/node_modules/shelljs/test/which.js new file mode 100644 index 0000000..ac9a04d --- /dev/null +++ b/wp8/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-wp8/blob/c2c2e564/wp8/package.json ---------------------------------------------------------------------- diff --git a/wp8/package.json b/wp8/package.json index 835d26e..82b1b64 100644 --- a/wp8/package.json +++ b/wp8/package.json @@ -13,6 +13,12 @@ "cordova", "apache" ], + "dependencies": { + "nopt": "~3", + "shelljs": "~0.3", + "node-uuid": "~1.4", + "q": "~1" + }, "devDependencies": { "jasmine-node": "~1", "shelljs": "0.1.x" http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/template/cordova/build ---------------------------------------------------------------------- diff --git a/wp8/template/cordova/build b/wp8/template/cordova/build new file mode 100644 index 0000000..8fbceae --- /dev/null +++ b/wp8/template/cordova/build @@ -0,0 +1,34 @@ +#!/usr/bin/env node + +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ + +var build = require('./lib/build'), + args = process.argv; + +// Handle help flag +if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(args[2]) > -1) { + build.help(); +} else { + build.run(args).done(null, function(err) { + var errorMessage = (err && err.stack) ? err.stack : err; + console.error('ERROR: ' + errorMessage); + process.exit(2); + }); +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/template/cordova/build.bat ---------------------------------------------------------------------- diff --git a/wp8/template/cordova/build.bat b/wp8/template/cordova/build.bat index 43d9f04..61acb6e 100644 --- a/wp8/template/cordova/build.bat +++ b/wp8/template/cordova/build.bat @@ -1,3 +1,4 @@ +@ECHO OFF goto endheader # # Licensed to the Apache Software Foundation (ASF) under one @@ -19,13 +20,11 @@ goto endheader # :endheader - -@ECHO OFF -SET script_path="%~dp0lib\build.js" +SET script_path="%~dp0build" IF EXIST %script_path% ( - cscript %script_path% %* //nologo + node %script_path% %* ) ELSE ( ECHO. - ECHO ERROR: Could not find 'build.js' in cordova/lib, aborting...>&2 + ECHO ERROR: Could not find 'build' in cordova, aborting...>&2 EXIT /B 1 ) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/template/cordova/clean ---------------------------------------------------------------------- diff --git a/wp8/template/cordova/clean b/wp8/template/cordova/clean new file mode 100644 index 0000000..71877fe --- /dev/null +++ b/wp8/template/cordova/clean @@ -0,0 +1,27 @@ +#!/usr/bin/env node + +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ + +var clean = require('./lib/clean'); + +clean.run(process.argv).done(null, function(err) { + console.error('ERROR: ' + err); + process.exit(2); +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/template/cordova/clean.bat ---------------------------------------------------------------------- diff --git a/wp8/template/cordova/clean.bat b/wp8/template/cordova/clean.bat index 4b2d6c7..8ca03ca 100644 --- a/wp8/template/cordova/clean.bat +++ b/wp8/template/cordova/clean.bat @@ -20,12 +20,11 @@ goto endheader # :endheader -@ECHO OFF -SET script_path="%~dp0lib\clean.js" +SET script_path="%~dp0clean" IF EXIST %script_path% ( - cscript %script_path% %* //nologo + node %script_path% %* ) ELSE ( ECHO. - ECHO ERROR: Could not find 'clean.js' in cordova/lib, aborting...>&2 + ECHO ERROR: Could not find 'clean' script in 'cordova' folder, aborting...>&2 EXIT /B 1 ) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/template/cordova/lib/CordovaDeploy/CordovaDeploy.sln ---------------------------------------------------------------------- diff --git a/wp8/template/cordova/lib/CordovaDeploy/CordovaDeploy.sln b/wp8/template/cordova/lib/CordovaDeploy/CordovaDeploy.sln deleted file mode 100644 index 64a798b..0000000 --- a/wp8/template/cordova/lib/CordovaDeploy/CordovaDeploy.sln +++ /dev/null @@ -1,38 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CordovaDeploy", "CordovaDeploy\CordovaDeploy.csproj", "{E752165B-AF59-4FF0-8601-A2A69FE09E0E}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E752165B-AF59-4FF0-8601-A2A69FE09E0E}.Debug|x86.ActiveCfg = Debug|x86 - {E752165B-AF59-4FF0-8601-A2A69FE09E0E}.Debug|x86.Build.0 = Debug|x86 - {E752165B-AF59-4FF0-8601-A2A69FE09E0E}.Release|x86.ActiveCfg = Release|x86 - {E752165B-AF59-4FF0-8601-A2A69FE09E0E}.Release|x86.Build.0 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c2c2e564/wp8/template/cordova/lib/CordovaDeploy/CordovaDeploy/CordovaDeploy.csproj ---------------------------------------------------------------------- diff --git a/wp8/template/cordova/lib/CordovaDeploy/CordovaDeploy/CordovaDeploy.csproj b/wp8/template/cordova/lib/CordovaDeploy/CordovaDeploy/CordovaDeploy.csproj deleted file mode 100644 index 70a3136..0000000 --- a/wp8/template/cordova/lib/CordovaDeploy/CordovaDeploy/CordovaDeploy.csproj +++ /dev/null @@ -1,96 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---> -<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">x86</Platform> - <ProductVersion>8.0.30703</ProductVersion> - <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{E752165B-AF59-4FF0-8601-A2A69FE09E0E}</ProjectGuid> - <OutputType>Exe</OutputType> - <AppDesignerFolder>Properties</AppDesignerFolder> - <RootNamespace>CordovaDeploy</RootNamespace> - <AssemblyName>CordovaDeploy</AssemblyName> - <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> - <TargetFrameworkProfile> - </TargetFrameworkProfile> - <FileAlignment>512</FileAlignment> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> - <PlatformTarget>x86</PlatformTarget> - <DebugSymbols>true</DebugSymbols> - <DebugType>full</DebugType> - <Optimize>false</Optimize> - <OutputPath>bin\Debug\</OutputPath> - <DefineConstants>DEBUG;TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <Prefer32Bit>false</Prefer32Bit> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> - <PlatformTarget>x86</PlatformTarget> - <DebugType>pdbonly</DebugType> - <Optimize>true</Optimize> - <OutputPath>bin\Release\</OutputPath> - <DefineConstants>TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <Prefer32Bit>false</Prefer32Bit> - </PropertyGroup> - <PropertyGroup> - <StartupObject>CordovaDeploy.DeployTool</StartupObject> - </PropertyGroup> - <ItemGroup> - <Reference Include="Microsoft.Smartdevice.Connectivity, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> - <SpecificVersion>True</SpecificVersion> - <HintPath>..\..\..\..\..\..\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SmartDevice.Connectivity\v4.0_11.0.0.0__b03f5f7f11d50a3a\Microsoft.Smartdevice.Connectivity.dll</HintPath> - </Reference> - <Reference Include="Microsoft.Smartdevice.Connectivity.Interface, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> - <SpecificVersion>True</SpecificVersion> - <HintPath>..\..\..\..\..\..\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SmartDevice.Connectivity.Interface\v4.0_11.0.0.0__b03f5f7f11d50a3a\Microsoft.Smartdevice.Connectivity.Interface.dll</HintPath> - </Reference> - <Reference Include="Microsoft.Smartdevice.MultiTargeting.Connectivity, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> - <SpecificVersion>True</SpecificVersion> - <HintPath>..\..\..\..\..\..\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SmartDevice.MultiTargeting.Connectivity\v4.0_11.0.0.0__b03f5f7f11d50a3a\Microsoft.Smartdevice.MultiTargeting.Connectivity.dll</HintPath> - </Reference> - <Reference Include="System" /> - <Reference Include="System.Core" /> - <Reference Include="System.Xml.Linq" /> - <Reference Include="System.Data.DataSetExtensions" /> - <Reference Include="Microsoft.CSharp" /> - <Reference Include="System.Data" /> - <Reference Include="System.Xml" /> - </ItemGroup> - <ItemGroup> - <Compile Include="Program.cs" /> - <Compile Include="Properties\AssemblyInfo.cs" /> - </ItemGroup> - <ItemGroup> - <None Include="app.config" /> - </ItemGroup> - <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> - --> -</Project> \ No newline at end of file
