Skip to content

Commit 4a25210

Browse files
committed
Created node function that read a file and output the file content on terminal
1 parent a715e1f commit 4a25210

3 files changed

Lines changed: 52 additions & 0 deletions

File tree

implement-shell-tools/cat/cat.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { program } from 'commander'
2+
import process from 'process'
3+
import fs from 'fs'
4+
5+
const argv = process.argv[2]
6+
const data = fs.readFileSync(`sample-files/${argv}`, 'utf-8')
7+
program
8+
.command('cat')
9+
.description('Output file content')
10+
.option('-a, --all', "show all users' processes")
11+
.action(console.log(data))

implement-shell-tools/cat/package-lock.json

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "cat",
3+
"version": "1.0.0",
4+
"description": "You should already be familiar with the `cat` command line tool.",
5+
"main": "cat.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [],
10+
"author": "",
11+
"license": "ISC",
12+
"type": "module",
13+
"dependencies": {
14+
"commander": "^14.0.3"
15+
}
16+
}

0 commit comments

Comments
 (0)