refactor(dload-file-inbuild-packages): log working and file directory

This commit is contained in:
dancingCycle 2022-06-06 08:27:53 +02:00
parent 4cdabceb57
commit fcff6fb321
1 changed files with 10 additions and 9 deletions

View File

@ -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');
})
})