diff options
Diffstat (limited to 'deps/npm/node_modules/tar/lib/create.js')
-rw-r--r-- | deps/npm/node_modules/tar/lib/create.js | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/deps/npm/node_modules/tar/lib/create.js b/deps/npm/node_modules/tar/lib/create.js index 5d46b3ba706..a37aa52e6d4 100644 --- a/deps/npm/node_modules/tar/lib/create.js +++ b/deps/npm/node_modules/tar/lib/create.js @@ -5,6 +5,7 @@ const hlo = require('./high-level-opt.js') const Pack = require('./pack.js') const fs = require('fs') +const fsm = require('fs-minipass') const t = require('./list.js') const path = require('path') @@ -36,24 +37,18 @@ const c = module.exports = (opt_, files, cb) => { const createFileSync = (opt, files) => { const p = new Pack.Sync(opt) - - let threw = true - let fd - try { - fd = fs.openSync(opt.file, 'w', opt.mode || 0o666) - p.on('data', chunk => fs.writeSync(fd, chunk, 0, chunk.length)) - p.on('end', _ => fs.closeSync(fd)) - addFilesSync(p, files) - threw = false - } finally { - if (threw) - try { fs.closeSync(fd) } catch (er) {} - } + const stream = new fsm.WriteStreamSync(opt.file, { + mode: opt.mode || 0o666 + }) + p.pipe(stream) + addFilesSync(p, files) } const createFile = (opt, files, cb) => { const p = new Pack(opt) - const stream = fs.createWriteStream(opt.file, { mode: opt.mode || 0o666 }) + const stream = new fsm.WriteStream(opt.file, { + mode: opt.mode || 0o666 + }) p.pipe(stream) const promise = new Promise((res, rej) => { |