refactor(dload-file-inbuild-packages): log working and file directory
This commit is contained in:
parent
4cdabceb57
commit
fcff6fb321
|
@ -23,19 +23,20 @@ const fs = require('fs');
|
||||||
* enable HTTP requests
|
* enable HTTP requests
|
||||||
*/
|
*/
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
|
|
||||||
/*
|
debug('process.cwd(): '+process.cwd());
|
||||||
* send HTTP GET request
|
//__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) => {
|
http.get(URL,(res) => {
|
||||||
/*
|
const path = `${__dirname}/dload`;
|
||||||
* image will be stored at this place
|
debug('path: '+path);
|
||||||
*/
|
//create file
|
||||||
const path = `${__dirname}/dload`;
|
|
||||||
const filePath = fs.createWriteStream(path);
|
const filePath = fs.createWriteStream(path);
|
||||||
res.pipe(filePath);
|
res.pipe(filePath);
|
||||||
filePath.on('finish',() => {
|
filePath.on('finish',() => {
|
||||||
filePath.close();
|
filePath.close();
|
||||||
console.log('Download Completed');
|
console.log('download Completed');
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue