[go: up one dir, main page]

Skip to content

Commit

Permalink
添加例子:查看当前目录文件
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jun 18, 2015
1 parent a37f395 commit 0d47d83
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions examples/ls.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env node

var fs = require("fs"),
path = process.cwd();

var run= function (obj) {
if(obj[0] === '-v'){
console.log('version is 1.0.0');
}else if(obj[0] === '-h'){
console.log('Useage:');
console.log(' -v --version [show version]');
}else{
fs.readdir(path, function(err, files){
if(err){
return console.log(err);
}
for(var i = 0; i < files.length; i += 1){
console.log(files[i]);
}
});
}
};
//获取除第一个命令以后的参数,使用空格拆分
run(process.argv.slice(2));

0 comments on commit 0d47d83

Please sign in to comment.