Merge pull request #28 from aeosynth/lsa

-a includes . and ..; -A does not
This commit is contained in:
Artur Adib 2012-09-23 17:01:47 -07:00
commit eb8ab8a02c
2 changed files with 7 additions and 7 deletions

View File

@ -64,7 +64,7 @@ exports.pwd = wrap('pwd', _pwd);
//@ Available options:
//@
//@ + `-R`: recursive
//@ + `-a`: all files (include files beginning with `.`)
//@ + `-A`: all files (include files beginning with `.`)
//@
//@ Examples:
//@
@ -78,7 +78,7 @@ exports.pwd = wrap('pwd', _pwd);
function _ls(options, paths) {
options = parseOptions(options, {
'R': 'recursive',
'a': 'all'
'A': 'all'
});
if (!paths)
@ -127,7 +127,7 @@ function _ls(options, paths) {
var oldDir = _pwd();
_cd('', p);
if (fs.statSync(file).isDirectory())
list = list.concat(_ls('-R'+(options.all?'a':''), file+'/*'));
list = list.concat(_ls('-R'+(options.all?'A':''), file+'/*'));
_cd('', oldDir);
}
});
@ -155,7 +155,7 @@ function _ls(options, paths) {
if (options.recursive) {
var pp = dirname + '/' + file;
if (fs.statSync(pp).isDirectory())
list = list.concat(_ls('-R'+(options.all?'a':''), pp+'/*'));
list = list.concat(_ls('-R'+(options.all?'A':''), pp+'/*'));
} // recursive
} // if file matches
}); // forEach
@ -208,7 +208,7 @@ function _find(options, paths) {
pushFile(file);
if (fs.statSync(file).isDirectory()) {
_ls('-Ra', file+'/*').forEach(function(subfile) {
_ls('-RA', file+'/*').forEach(function(subfile) {
pushFile(subfile);
});
}

View File

@ -61,7 +61,7 @@ assert.equal(result.length, 6);
// no args, 'all' option
shell.cd('resources/ls');
var result = shell.ls('-a');
var result = shell.ls('-A');
assert.equal(shell.error(), null);
assert.equal(result.indexOf('file1') > -1, true);
assert.equal(result.indexOf('file2') > -1, true);
@ -168,7 +168,7 @@ 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');
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);