-
Notifications
You must be signed in to change notification settings - Fork 0
/
tardcmp.js
22 lines (20 loc) · 675 Bytes
/
tardcmp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const untar = require('./untar')
const xzdec = require('./xzdec')
const { inflate: gzdec } = require('pako')
const { decompress: lzmadec } = require('lzma/src/lzma_worker-min').LZMA
module.exports = function (tarName, tarData) {
let dataTarContent
if (tarName.endsWith('/')) {
tarName = tarName.substr(0, tarName.length - 1)
}
if (tarName === 'data.tar') {
dataTarContent = tarData
} else if (tarName.endsWith('.xz')) {
dataTarContent = xzdec(tarData)
} else if (tarName.endsWith('.lzma')) {
dataTarContent = lzmadec(tarData)
} else if (tarName.endsWith('.gz')) {
dataTarContent = gzdec(tarData)
}
return untar.untar(dataTarContent)
}