diff --git a/tasks/sdk.js b/tasks/sdk.js index 5d36628..efc28b5 100755 --- a/tasks/sdk.js +++ b/tasks/sdk.js @@ -85,7 +85,19 @@ class Sdk { let stream = got.stream(this.link); stream = stream.on('downloadProgress', (p) => bar.update(p.percent)); 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')) { stream = stream.pipe(tar.x({C: this.path, strip: 1})); } else { @@ -98,4 +110,4 @@ class Sdk { Sdk.System = System; -module.exports = Sdk; \ No newline at end of file +module.exports = Sdk;