Skip to content

Commit

Permalink
build: Replace exec with spawn
Browse files Browse the repository at this point in the history
Signed-off-by: eXhumer <exhumer1@protonmail.com>
  • Loading branch information
eXhumer committed Apr 19, 2024
1 parent d07a1ae commit 5b2a710
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions forge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,33 @@ import { notarize } from '@electron/notarize';

import { mainConfig } from './webpack/main.config';
import { rendererConfig } from './webpack/renderer.config';
import { promisify } from 'util';
import { exec } from 'child_process';
import { spawn, SpawnOptionsWithoutStdio } from 'child_process';
import { config as dotenvConfig } from 'dotenv';
import { join, resolve } from 'path';

import { author, productName } from './package.json';

dotenvConfig();

const execPromise = promisify(exec);
const spawnPromise = (command: string, args?: string[], options?: SpawnOptionsWithoutStdio) => {
return new Promise<void>((resolve, reject) => {
const child = spawn(command, args, options);

child.on('exit', code => {
if (code === 0)
resolve();
else
reject(new Error(`Command "${command} ${args ? args.join(' ') : ''}" exited with code ${code}`));
});

child.on('error', reject);
});
};

const vmpSignPkg = async (pkgPath: string, username: string, password: string) => {
await execPromise(`python -m pip install --upgrade castlabs-evs`);
await execPromise(`python -m castlabs_evs.account reauth --account-name "${username}" --passwd "${password}"`);
await execPromise(`python -m castlabs_evs.vmp sign-pkg "${pkgPath}"`);
await spawnPromise('python', ['-m', 'pip', 'install', '--upgrade', 'castlabs-evs']);
await spawnPromise('python', ['-m', 'castlabs_evs.account', 'reauth', '--account-name', username, '--passwd', password]);
await spawnPromise('python', ['-m', 'castlabs_evs.vmp', 'sign-pkg', pkgPath]);
};

const osxSignPkg = async (pkgPath: string, optionsForFile?: (path: string) => PerFileSignOptions) => {
Expand Down

0 comments on commit 5b2a710

Please sign in to comment.