Created
June 10, 2017 14:48
-
-
Save mantovanirian/c9ca7b7ec154e39dc969b60bf691aaf8 to your computer and use it in GitHub Desktop.
fbsimctl function on node-simctl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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