askui
Version:
Reliable, automated end-to-end-testing that depends on what is shown on your screen instead of the technology you are running on
32 lines (31 loc) • 1.21 kB
JavaScript
import { exec, execSync } from 'child_process';
import fs from 'fs-extra';
import path from 'path';
import { UiControllerFacade } from './ui-controller-facade';
import { logger } from './logger';
export class UiControllerDarwin extends UiControllerFacade {
makeBinaryExecutable() {
this.makeDiskImageExecutable();
}
getStartingCommand() {
return `"${path.dirname(this.binaryFilePath)}/askui-ui-controller.app/Contents/MacOS/askui-ui-controller"`;
}
makeDiskImageExecutable() {
const mountPoint = '/Volumes/askui-ui-controller.dmg';
execSync([
'hdiutil attach',
'-nobrowse',
'-quiet',
'-noautofsck',
'-noautoopen',
`-mountpoint "${mountPoint}"`,
`"${this.binaryFilePath}"`,
].join(' '));
const appBaseName = 'askui-ui-controller.app';
const appSrcPath = `${mountPoint}/${appBaseName}`;
const appDestPath = `${path.dirname(this.binaryFilePath)}/${appBaseName}`;
fs.removeSync(appDestPath);
fs.copySync(appSrcPath, appDestPath);
exec(`hdiutil detach "${mountPoint}"`, (_exception, stdout) => logger.debug(stdout));
}
}