Newbie to Node here. I'm trying to download a .tar.xz
file and extract it to a directory via the code shown below:
var request = require('request');
var tar = require('tar');
var xz = require('xz');
function downloadRaw(url, callback)
{
return request({
encoding: null,
url: url
}, callback);
}
function extractToDirectory(url, directory, callback)
{
return downloadRaw(url)
.pipe(new xz.Decompressor())
.pipe(tar.Extract(directory))
.on('finish', callback);
}
For some reason, the 'finish'
event on the tar stream does not seem to be firing, even after it finishes extracting the contents of the archive. tar is a library that's maintained by npm themselves, so I assume that I'm making some kind of mistake here. Anyway, why is this happening and what can I do to fix it?