From 7fca2fdfd71662bf922e606f388100f03604c961 Mon Sep 17 00:00:00 2001 From: Paul Varache Date: Tue, 7 Aug 2018 15:12:46 +0100 Subject: [PATCH] Update ditto archiver --- lib/archivers/ditto.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/archivers/ditto.js b/lib/archivers/ditto.js index 6f1870c..e5a5bb2 100644 --- a/lib/archivers/ditto.js +++ b/lib/archivers/ditto.js @@ -2,12 +2,13 @@ const cp = require('child_process'); const path = require('path'); const fs = require('fs'); const os = require('os'); +const { PassThrough } = require('stream'); function createZipWithDitto(basedir, file, target) { target = target + '.zip'; return new Promise((resolve, reject) => { let cmd = 'ditto', - args = ['-ck', '--rsrc', '--sequesterRsrc', '--keepParent', file, target], + args = ['-ck', '--rsrc', '--sequesterRsrc', file, target], p; console.log(`[ZIP] ${cmd} ${args.join(' ')}`); p = cp.spawn(cmd, args, { cwd: basedir }); @@ -26,13 +27,15 @@ function createZipWithDitto(basedir, file, target) { module.exports = { archive(buildDir) { - const baseDir = path.dirname(buildDir); - const name = buildDir.split('/').pop(); - const target = path.join(os.tmpdir(), 'kart-ditto-tmp'); - return createZipWithDitto(baseDir, name, target) - .then(() => { - return fs.createReadStream(`${target}.zip`); - }); + const baseDir = path.dirname(buildDir); + const name = buildDir.split('/').pop(); + const target = path.join(os.tmpdir(), 'kart-ditto-tmp'); + const stream = new PassThrough(); + createZipWithDitto(baseDir, name, target) + .then((file) => { + fs.createReadStream(file).pipe(stream) + }); + return stream; }, extension() { return 'zip';