Skip to content

Commit bc140a3

Browse files
committed
feat(cat): add basic cat CLI
Add cat/cat.js which reads a file path from argv and prints the file contents using node fs promises and top-level await. Logs argv and path (debug output).
1 parent 4350f48 commit bc140a3

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

  • implement-shell-tools/cat

implement-shell-tools/cat/cat.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import process from "node:process";
2+
import { promises as fs } from "node:fs";
3+
4+
const argv = process.argv.slice(2);
5+
console.log(argv);
6+
7+
const path = argv[0];
8+
9+
console.log(path);
10+
11+
const content = await fs.readFile(path, "utf-8");
12+
console.log(content.trim());

0 commit comments

Comments
 (0)