-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogram.js
28 lines (28 loc) · 817 Bytes
/
program.js
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
// Sync
/*var fs = require('fs');
var pathToFile = process.argv[2];
var bufferObj = fs.readFileSync(pathToFile);
console.log(bufferObj.toString().split('\n').length - 1);*/
//Async
// var fs = require("fs");
// var pathToFile = process.argv[2];
// fs.readFile(pathToFile, 'utf-8',
// function(err, bufferObj){
// if(err !== null) {
// console.log(err);
// return;
// }
// console.log(bufferObj.toString().split('\n').length - 1);
// });
// filter files
var pathToDir = process.argv[2];
var extensionToFilter = process.argv[3];
var readDir = require("./readDir.js");
var printDirList = function(error, data) {
if(error) {
console.error("There was an error: " + error);
return;
}
data.forEach(function(fileName) { console.log(fileName) ; });
};
readDir(pathToDir, extensionToFilter, printDirList);