- Extract 4756 source files from cli.js.map (57MB) - Set up Bun build system with bun:bundle feature flag shim - Configure 90+ compile-time feature flags matching production defaults - Inject MACRO constants (VERSION, BUILD_TIME, etc.) - Create stubs for private packages (color-diff-napi, modifiers-napi, etc.) - Install all public dependencies via pnpm - Patch commander v14 to allow multi-char short flags (-d2e) - Build output: dist/cli.js (22MB), verified working
38 lines
1006 B
JavaScript
38 lines
1006 B
JavaScript
import process from 'node:process';
|
|
import {promisify} from 'node:util';
|
|
import {execFile, execFileSync} from 'node:child_process';
|
|
|
|
const execFileAsync = promisify(execFile);
|
|
|
|
export async function runAppleScript(script, {humanReadableOutput = true, signal} = {}) {
|
|
if (process.platform !== 'darwin') {
|
|
throw new Error('macOS only');
|
|
}
|
|
|
|
const outputArguments = humanReadableOutput ? [] : ['-ss'];
|
|
|
|
const execOptions = {};
|
|
if (signal) {
|
|
execOptions.signal = signal;
|
|
}
|
|
|
|
const {stdout} = await execFileAsync('osascript', ['-e', script, outputArguments], execOptions);
|
|
return stdout.trim();
|
|
}
|
|
|
|
export function runAppleScriptSync(script, {humanReadableOutput = true} = {}) {
|
|
if (process.platform !== 'darwin') {
|
|
throw new Error('macOS only');
|
|
}
|
|
|
|
const outputArguments = humanReadableOutput ? [] : ['-ss'];
|
|
|
|
const stdout = execFileSync('osascript', ['-e', script, ...outputArguments], {
|
|
encoding: 'utf8',
|
|
stdio: ['ignore', 'pipe', 'ignore'],
|
|
timeout: 500,
|
|
});
|
|
|
|
return stdout.trim();
|
|
}
|