From 460c703857090b64b3067c83e3bdd56cd8fdc175 Mon Sep 17 00:00:00 2001 From: wendy munyasi Date: Tue, 18 Oct 2022 22:28:06 +0300 Subject: [PATCH] Add script that reads/ prins file content - task 0 --- 0x14-javascript-web_scraping/0-readme.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 0x14-javascript-web_scraping/0-readme.js diff --git a/0x14-javascript-web_scraping/0-readme.js b/0x14-javascript-web_scraping/0-readme.js new file mode 100755 index 0000000..1ae6e12 --- /dev/null +++ b/0x14-javascript-web_scraping/0-readme.js @@ -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); + } +});