-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script that reads/ prins file content - task 0
- Loading branch information
1 parent
5615212
commit 460c703
Showing
1 changed file
with
15 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/node | ||
const process = require('process'); | ||
const fs = require('fs'); | ||
|
||
// The first argument is the file path | ||
const file = process.argv[2]; | ||
|
||
fs.readFile(file, 'utf8', function (err, data) { | ||
// If an error occurred during the reading, print the error object | ||
if (err) { | ||
console.log(err); | ||
} else { | ||
process.stdout.write(data); | ||
} | ||
}); |