replace 'mkdirp' and 'rmdir' usage with 'fs-extra'
This commit is contained in:
@@ -8,7 +8,7 @@ const tar = require('tar');
|
||||
const ProgressBar = require('progress');
|
||||
const colors = require('ansi-colors');
|
||||
const log = require('fancy-log');
|
||||
const mkdirp = require('mkdirp');
|
||||
const fse = require('fs-extra');
|
||||
|
||||
|
||||
class System {
|
||||
@@ -81,7 +81,7 @@ class Sdk {
|
||||
if (this.prepared) {
|
||||
return Promise.resolve();
|
||||
} else {
|
||||
mkdirp.sync(this.path);
|
||||
fse.ensureDirSync(this.path);
|
||||
const bar = new ProgressBar(`${this.tag} [:bar] :percent :etas`, {width: 40, total: 1000, clear: true});
|
||||
let stream = got.stream(this.link);
|
||||
stream = stream.on('downloadProgress', (p) => bar.update(p.percent));
|
||||
@@ -90,7 +90,7 @@ class Sdk {
|
||||
const filePath = entry.path.split('/').slice(1).join(path.sep);
|
||||
if (filePath.length > 0) {
|
||||
if (entry.type === 'Directory') {
|
||||
mkdirp(path.join(this.path, path.normalize(filePath)));
|
||||
fse.ensureDirSync(path.join(this.path, path.normalize(filePath)));
|
||||
} else if (entry.type === 'File') {
|
||||
entry.pipe(fs.createWriteStream(path.join(this.path, path.normalize(filePath))));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user