Skip to content

Commit

Permalink
Update ditto archiver
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Varache committed Aug 7, 2018
1 parent 765e37d commit 7fca2fd
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib/archivers/ditto.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand All @@ -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';
Expand Down

0 comments on commit 7fca2fd

Please sign in to comment.