Skip to content

Commit f9f0938

Browse files
committed
Section 24: Console Logs with Colors
1 parent 0e33ce4 commit f9f0938

4 files changed

Lines changed: 145 additions & 1 deletion

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/node_modules
2+
node_modules/

24-Create-Node-JS-Command-Line-Tools/02-list/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
const fs = require('fs')
55
const util = require('util')
6+
const chalk = require('chalk')
67

78
// Method #2
89
// const lstat = util.promisify(fs.lstat)
@@ -24,7 +25,11 @@ fs.readdir(process.cwd(), async (err, filenames) => {
2425
for(let stats of allStats) {
2526
const index = allStats.indexOf(stats)
2627

27-
console.log(filenames[index], stats.isFile());
28+
if(stats.isFile()) {
29+
console.log(filenames[index]);
30+
} else {
31+
console.log(chalk.bold(filenames[index]));
32+
}
2833
}
2934
})
3035

24-Create-Node-JS-Command-Line-Tools/02-list/package-lock.json

Lines changed: 134 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

24-Create-Node-JS-Command-Line-Tools/02-list/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@
1111
"license": "ISC",
1212
"bin": {
1313
"nls": "index.js"
14+
},
15+
"dependencies": {
16+
"chalk": "^2.4.2"
1417
}
1518
}

0 commit comments

Comments
 (0)