replace 'mkdirp' and 'rmdir' usage with 'fs-extra'

This commit is contained in:
2018-04-28 17:08:22 +03:00
parent 00d9ec5c0e
commit 28ad6f9c81
4 changed files with 12 additions and 17 deletions

View File

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