mirror of
https://github.com/shelljs/shelljs.git
synced 2026-01-18 16:03:37 +00:00
Merge pull request #28 from aeosynth/lsa
-a includes . and ..; -A does not
This commit is contained in:
commit
eb8ab8a02c
10
shell.js
10
shell.js
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user