ls, cp pass

This commit is contained in:
Artur Adib 2012-03-01 21:11:34 -05:00
parent 34bfe3ba1f
commit ca71bb8380
3 changed files with 20 additions and 8 deletions

View File

@ -178,8 +178,10 @@ function _cp(options, sources, dest) {
if (arguments.length < 3) {
error('missing <source> and/or <dest>');
} else if (arguments.length > 3) {
sources = [].slice.call(arguments, 1, arguments.length - 2);
sources = [].slice.call(arguments, 1, arguments.length - 1);
dest = arguments[arguments.length - 1];
} else {
sources = [sources];
}
// Dest is not existing dir, but multiple sources given
@ -393,15 +395,16 @@ function _mkdir(options, str) {
exports.mkdir = wrap('mkdir', _mkdir);
//@
//@ #### cat('file [file ...]')
//@ #### cat(file [, file ...]')
//@ Returns a string containing the given file, or a concatenated string
//@ containing the files if more than one file is given (a new line character is
//@ introduced between each file). Wildcards are accepted.
function _cat(options, str) {
var files = parsePaths(str),
//@ introduced between each file). Wildcard `*` accepted.
function _cat(options, files) {
var files = [].slice.call(arguments, 1),
cat = '';
files = expand(files);
if (files.length === 0)
error('no files given');

View File

@ -84,7 +84,7 @@ assert.equal(fs.existsSync('tmp/file2'), true);
shell.rm('-rf', 'tmp/*');
shell.cp('-R', 'resources/cp', 'tmp');
assert.equal(shell.error(), null);
assert.deepEqual(shell.ls('-R', 'resources/cp'), ls('-R', 'tmp/cp'));
assert.deepEqual(shell.ls('-R', 'resources/cp'), shell.ls('-R', 'tmp/cp'));
//recursive, everything exists, no force flag
shell.rm('-rf', 'tmp/*')

View File

@ -34,7 +34,7 @@ assert.equal(shell.error(), null);
// no args
shell.cd('resources/ls');
var result = shell.ls().hash;
var result = shell.ls();
assert.equal(shell.error(), null);
assert.equal('file1' in result, true);
assert.equal('file2' in result, true);
@ -46,7 +46,7 @@ assert.equal(Object.keys(result).length, 6);
shell.cd('../..');
// simple arg
var result = shell.ls('resources/ls').hash;
var result = shell.ls('resources/ls');
assert.equal(shell.error(), null);
assert.equal('file1' in result, true);
assert.equal('file2' in result, true);
@ -124,6 +124,15 @@ assert.equal('resources/ls/file2.js' in result, true);
assert.equal('resources/ls/a_dir/b_dir' in result, true);
assert.equal('resources/ls/a_dir/nada' in result, 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(Object.keys(result).length, 4);
assert.equal('resources/ls/file1.js' in result, true);
assert.equal('resources/ls/file2.js' in result, true);
assert.equal('resources/ls/a_dir/b_dir' in result, true);
assert.equal('resources/ls/a_dir/nada' in result, true);
// recursive, no path
shell.cd('resources/ls');
var result = shell.ls('-R');