[build] update sdk.js
This commit is contained in:
16
tasks/sdk.js
16
tasks/sdk.js
@@ -85,7 +85,19 @@ class Sdk {
|
|||||||
let stream = got.stream(this.link);
|
let stream = got.stream(this.link);
|
||||||
stream = stream.on('downloadProgress', (p) => bar.update(p.percent));
|
stream = stream.on('downloadProgress', (p) => bar.update(p.percent));
|
||||||
if (this.link.endsWith('.zip')) {
|
if (this.link.endsWith('.zip')) {
|
||||||
stream = stream.pipe(unzip.Extract({path: this.path}));
|
const sep = '/';
|
||||||
|
stream = stream.pipe(unzip.Parse()).on('entry', (entry) => {
|
||||||
|
const filePath = entry.path.split(sep).slice(1).join(sep);
|
||||||
|
if (filePath.length > 0) {
|
||||||
|
if (entry.type === 'Directory') {
|
||||||
|
mkdirp(this.path + sep + filePath);
|
||||||
|
} else if (entry.type === 'File') {
|
||||||
|
entry.pipe(fs.createWriteStream(this.path + sep + filePath));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
entry.autodrain();
|
||||||
|
}
|
||||||
|
});
|
||||||
} else if (this.link.endsWith('tar.gz')) {
|
} else if (this.link.endsWith('tar.gz')) {
|
||||||
stream = stream.pipe(tar.x({C: this.path, strip: 1}));
|
stream = stream.pipe(tar.x({C: this.path, strip: 1}));
|
||||||
} else {
|
} else {
|
||||||
@@ -98,4 +110,4 @@ class Sdk {
|
|||||||
|
|
||||||
Sdk.System = System;
|
Sdk.System = System;
|
||||||
|
|
||||||
module.exports = Sdk;
|
module.exports = Sdk;
|
||||||
|
|||||||
Reference in New Issue
Block a user