Skip to content

Instantly share code, notes, and snippets.

@mantovanirian
Created June 10, 2017 14:48
Show Gist options
  • Save mantovanirian/c9ca7b7ec154e39dc969b60bf691aaf8 to your computer and use it in GitHub Desktop.
Save mantovanirian/c9ca7b7ec154e39dc969b60bf691aaf8 to your computer and use it in GitHub Desktop.
fbsimctl function on node-simctl
async function simCommand (command:string, timeout:number, args:Array = [], env = {}, executingFunction = exec) {
// run a particular simctl command
args = [command, ...args];
// Prefix all passed in environment variables with 'SIMCTL_CHILD_', simctl
// will then pass these to the child (spawned) process.
env = _.defaults(_.mapKeys(env, function(value, key) {
return `SIMCTL_CHILD_${key}`;
}), process.env);
try {
return await executingFunction('fbsimctl', args, {timeout, env});
} catch (e) {
if (e.stderr) {
log.errorAndThrow(`simctl error running '${command}': ${e.stderr.trim()}`);
} else {
log.errorAndThrow(e);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment