Skip to content

Commit cd7ccde

Browse files
committed
Add cat.js
1 parent 4350f48 commit cd7ccde

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+
if (argv.length != 1) {
6+
console.error(`Expected exactly 1 argument (a path) to be passed but got ${argv.length}.`);
7+
process.exit(1);
8+
}
9+
const path = argv[0];
10+
const content = await fs.readFile(path, "utf-8");
11+
12+
console.log(content);

0 commit comments

Comments
 (0)