|
@@ -1,6 +1,10 @@
|
|
const fs = require('fs');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const path = require('path');
|
|
-const dl = require('download-file-with-progressbar');
|
|
|
|
|
|
+// const dl = require('download-file-with-progressbar');
|
|
|
|
+const {
|
|
|
|
+ DownloaderHelper
|
|
|
|
+} = require('node-downloader-helper');
|
|
|
|
+
|
|
|
|
|
|
module.exports = {
|
|
module.exports = {
|
|
getCurrentDirectoryBase: () => {
|
|
getCurrentDirectoryBase: () => {
|
|
@@ -28,19 +32,36 @@ module.exports = {
|
|
console.log(err)
|
|
console.log(err)
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- downloadFile: async (element) => {
|
|
|
|
- option = {
|
|
|
|
- dir: './data/apps',
|
|
|
|
- onDone: (info)=>{
|
|
|
|
- console.log('Latest ' + element.name + ' Downloaded')
|
|
|
|
- },
|
|
|
|
- onError: (err) => {
|
|
|
|
- console.log('error', err);
|
|
|
|
- },
|
|
|
|
- onProgress: (curr, total) => {
|
|
|
|
- },
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- var dd = dl(element.url, option);
|
|
|
|
- }
|
|
|
|
-};
|
|
|
|
|
|
+ downloadFile: (element) => {
|
|
|
|
+ // option = {
|
|
|
|
+ // dir: './data/apps',
|
|
|
|
+ // onDone: (info) => {
|
|
|
|
+ // console.log('Latest ' + element.name + ' Downloaded')
|
|
|
|
+ // },
|
|
|
|
+ // onError: (err) => {
|
|
|
|
+ // console.log('error', err);
|
|
|
|
+ // },
|
|
|
|
+ // onProgress: (curr, total) => {},
|
|
|
|
+ // }
|
|
|
|
+ // dl(element.url, option);
|
|
|
|
+ // }
|
|
|
|
+ // const options = {
|
|
|
|
+ // override: true,
|
|
|
|
+ // }
|
|
|
|
+ // const dl = new DownloaderHelper(element.url, './data/apps', options);
|
|
|
|
+
|
|
|
|
+ // dl.on('end', () => console.log('Download Completed'))
|
|
|
|
+
|
|
|
|
+ // dl.start();
|
|
|
|
+ var promise = new Promise(function (resolve, reject) {
|
|
|
|
+ setTimeout(function () {
|
|
|
|
+ resolve('hello world');
|
|
|
|
+ }, 2000);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ promise.then(function (data) {
|
|
|
|
+ console.log(data);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+}
|