-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommands.js
More file actions
39 lines (37 loc) · 1 KB
/
commands.js
File metadata and controls
39 lines (37 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
var fs = require('fs');
module.exports = {
'ls': function(){fs.readdir('.', function(err, files) {
if (err) throw err;
files.forEach(function(file) {
process.stdout.write(file.toString() + '\n');
});
process.stdout.write('prompt > ');
})},
'pwd': function(){
process.stdout.write(process.cwd());
process.stdout.write('\nprompt > ');
},
'date': function(){
process.stdout.write(new Date().toUTCString());
process.stdout.write('\nprompt > ');
},
'echo': function(arg){
var newArg = arg.slice(1).join(' ');
process.stdout.write(newArg);
process.stdout.write('\nprompt > ');
},
'cat': function(file){
fs.readFile(file[1], function(err, catFile) {
if (err) throw err;
process.stdout.write(catFile);
process.stdout.write('\nprompt > ');
});
},
'head': function(file){
fs.readFile(file[1],function(err,catFile){
if(err) throw err;
process.stdout.write(catFile);
process.stdout.write('\nprompt > ');
});
}
}