Skip to content

Commit

Permalink
fix(flat): use pkgbuild to bundle pre/postinstall scripts (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
rickymohk authored Jul 4, 2024
1 parent 3b3a1b5 commit 51531f1
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/flat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,22 @@ async function validateFlatOpts (opts: FlatOptions): Promise<ValidatedFlatOption
* @returns {Promise} Promise.
*/
async function buildApplicationPkg (opts: ValidatedFlatOptions, identity: Identity) {
const args = ['--component', opts.app, opts.install, '--sign', identity.name, opts.pkg];
const componentPkgPath = path.join(path.dirname(opts.app), path.basename(opts.app, '.app') + '-component.pkg');
const pkgbuildArgs = ['--install-location', opts.install, '--component', opts.app, componentPkgPath];
if (opts.scripts) {
pkgbuildArgs.unshift('--scripts', opts.scripts);
}
debugLog('Building component package... ' + opts.app);
await execFileAsync('pkgbuild', pkgbuildArgs);

const args = ['--package', componentPkgPath, opts.install, '--sign', identity.name, opts.pkg];
if (opts.keychain) {
args.unshift('--keychain', opts.keychain);
}
if (opts.scripts) {
args.unshift('--scripts', opts.scripts);
}

debugLog('Flattening... ' + opts.app);
await execFileAsync('productbuild', args);
await execFileAsync('rm', [componentPkgPath]);
}

/**
Expand Down

0 comments on commit 51531f1

Please sign in to comment.