blob: d29517e49f2b08cc40d533bc81a9169467350546 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
// request a tar file, and then write it
require("http").request({...}, function (resp) {
resp.pipe(tar.createParser(function (file) {
if (file.isDirectory()) {
this.pause()
return fs.mkdir(file.name, function (er) {
if (er) return this.emit("error", er)
this.resume()
})
} else if (file.isSymbolicLink()) {
this.pause()
return fs.symlink(file.link, file.name, function (er) {
if (er) return this.emit("error", er)
this.resume()
})
} else if (file.isFile()) {
file.pipe(fs.createWriteStream(file.name))
}
}))
// or maybe just have it do all that internally?
resp.pipe(tar.createParser(function (file) {
this.create("/extract/target/path", file)
}))
})
|