Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function openProjectInEditorAsync(dir: string) {
if (process.platform === 'darwin') {
// This will use the ENV var $EXPO_EDITOR if set, or else will try various
// popular editors, looking for one that is open, or if none are, one that is installed
return await osascript.openInEditorAsync(dir, process.env.EXPO_EDITOR);
} else {
throw new XDLError('PLATFORM_NOT_SUPPORTED', 'openProjectInEditorAsync not supported');
}
}
export async function openFileInEditorAsync(path: string) {
if (process.platform === 'darwin') {
// This will use the ENV var $EXPO_EDITOR if set, or else will try various
// popular editors, looking for one that is open, or if none are, one that is installed
return await osascript.openInEditorAsync(path, process.env.EXPO_EDITOR);
} else {
throw new XDLError('PLATFORM_NOT_SUPPORTED', 'openFileInEditorAsync not supported');
}
}
export async function _isSimulatorInstalledAsync() {
let result;
try {
result = (await osascript.execAsync('id of app "Simulator"')).trim();
} catch (e) {
console.error(
"Can't determine id of Simulator app; the Simulator is most likely not installed on this machine",
e
);
Logger.global.error(XCODE_NOT_INSTALLED_ERROR);
return false;
}
if (
result !== 'com.apple.iphonesimulator' &&
result !== 'com.apple.CoreSimulator.SimulatorTrampoline'
) {
console.warn(
"Simulator is installed but is identified as '" + result + "'; don't know what that is."
);
Logger.global.error(XCODE_NOT_INSTALLED_ERROR);
export async function _isSimulatorRunningAsync() {
let zeroMeansNo = (
await osascript.execAsync(
'tell app "System Events" to count processes whose name is "Simulator"'
)
).trim();
if (zeroMeansNo === '0') {
return false;
}
return true;
}
export async function _quitSimulatorAsync() {
return await osascript.execAsync('tell application "Simulator" to quit');
}
export async function openFolderAsync(dir: string) {
if (process.platform === 'darwin') {
return await osascript.openFinderToFolderAsync(dir);
} else if (process.platform === 'win32') {
return await spawnAsync('explorer', [dir]);
} else {
throw new XDLError('PLATFORM_NOT_SUPPORTED', 'openFolderAsync not supported');
}
}
export async function openConsoleAsync(dir: string) {
if (process.platform === 'darwin') {
await osascript.openFolderInTerminalAppAsync(dir);
} else if (process.platform === 'win32') {
execSync(`start cmd /K "cd /d ${dir}"`);
} else {
throw new XDLError('PLATFORM_NOT_SUPPORTED', 'openConsoleAsync not supported');
}
}