How to use @expo/osascript - 7 common examples

To help you get started, we’ve selected a few @expo/osascript examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github expo / expo-cli / packages / xdl / src / FileSystem.ts View on Github external
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');
  }
}
github expo / expo-cli / packages / xdl / src / FileSystem.ts View on Github external
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');
  }
}
github expo / expo-cli / packages / xdl / src / Simulator.ts View on Github external
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);
github expo / expo-cli / packages / xdl / src / Simulator.ts View on Github external
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;
}
github expo / expo-cli / packages / xdl / src / Simulator.ts View on Github external
export async function _quitSimulatorAsync() {
  return await osascript.execAsync('tell application "Simulator" to quit');
}
github expo / expo-cli / packages / xdl / src / FileSystem.ts View on Github external
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');
  }
}
github expo / expo-cli / packages / xdl / src / FileSystem.ts View on Github external
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');
  }
}

@expo/osascript

Tools for running an osascripts in Node

MIT
Latest version published 5 months ago

Package Health Score

88 / 100
Full package analysis