From fcff6fb32115acd671b8d8f3c0238810172f880f Mon Sep 17 00:00:00 2001 From: "Begerad, Stefan" Date: Mon, 6 Jun 2022 08:27:53 +0200 Subject: [PATCH] refactor(dload-file-inbuild-packages): log working and file directory --- dload-file-inbuild-packages/index.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/dload-file-inbuild-packages/index.js b/dload-file-inbuild-packages/index.js index ca2e02b..02aedca 100644 --- a/dload-file-inbuild-packages/index.js +++ b/dload-file-inbuild-packages/index.js @@ -23,19 +23,20 @@ const fs = require('fs'); * enable HTTP requests */ const http = require('http'); - -/* - * send HTTP GET request - */ + +debug('process.cwd(): '+process.cwd()); +//__dirname is an env variable that tells you the absolute path of the directory containing the currently executing file +debug('__dirname: '+__dirname); + +//send HTTP GET request http.get(URL,(res) => { - /* - * image will be stored at this place - */ - const path = `${__dirname}/dload`; + const path = `${__dirname}/dload`; + debug('path: '+path); + //create file const filePath = fs.createWriteStream(path); res.pipe(filePath); filePath.on('finish',() => { filePath.close(); - console.log('Download Completed'); + console.log('download Completed'); }) })