fix(extension): fix unpack extension

This commit is contained in:
purocean
2022-05-19 21:44:21 +08:00
parent 381e9cb10f
commit 4cfd1acf0f
+10 -6
View File
@@ -89,13 +89,17 @@ export async function install (id: string, url: string) {
extract.on('entry', (header, stream, next) => {
const filePath = path.join(extensionPath, header.name.replace(/^package/, ''))
console.log('[extension] write file', filePath)
console.log('[extension] write', header.type, filePath)
fs.ensureFile(filePath).then(() => {
const fileStream = fs.createWriteStream(filePath)
stream.pipe(fileStream)
stream.on('end', next)
}).catch(reject)
if (header.type === 'file') {
fs.ensureFile(filePath).then(() => {
const fileStream = fs.createWriteStream(filePath)
stream.pipe(fileStream)
stream.on('end', next)
}).catch(reject)
} else {
next()
}
})
extract.on('finish', () => {