Wrap command execution in util
Summary: Take the low level execution details out of the healthchecks. The xcode-select change is sound because `xcode-select -p` returns status code > 0 when not set, so exec will throw, so no need to inspect stdout. Reviewed By: passy Differential Revision: D18449564 fbshipit-source-id: b2e2797a51aca45cfd78e707e99341798401897c
This commit is contained in:
committed by
Facebook Github Bot
parent
999e3784b8
commit
22a86747d4
@@ -44,9 +44,7 @@ export function getHealthchecks(): Healthchecks {
|
||||
label: 'OpenSSL Installed',
|
||||
isRequired: true,
|
||||
run: async (_: EnvironmentInfo) => {
|
||||
const isAvailable = await promisify(exec)('openssl version')
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
const isAvailable = await commandSucceeds('openssl version');
|
||||
return {
|
||||
hasProblem: !isAvailable,
|
||||
};
|
||||
@@ -91,20 +89,16 @@ export function getHealthchecks(): Healthchecks {
|
||||
label: 'xcode-select set',
|
||||
isRequired: true,
|
||||
run: async (_: EnvironmentInfo) => ({
|
||||
hasProblem:
|
||||
(await promisify(exec)('xcode-select -p')).stdout.trim()
|
||||
.length < 1,
|
||||
hasProblem: !(await commandSucceeds('xcode-select -p')),
|
||||
}),
|
||||
},
|
||||
{
|
||||
label: 'Instruments exists',
|
||||
isRequired: true,
|
||||
run: async (_: EnvironmentInfo) => {
|
||||
const hasInstruments = await promisify(exec)(
|
||||
const hasInstruments = await commandSucceeds(
|
||||
'which instruments',
|
||||
)
|
||||
.then(_ => true)
|
||||
.catch(_ => false);
|
||||
);
|
||||
|
||||
return {
|
||||
hasProblem: !hasInstruments,
|
||||
@@ -146,3 +140,9 @@ export async function runHealthchecks() {
|
||||
);
|
||||
return results;
|
||||
}
|
||||
|
||||
async function commandSucceeds(command: string): Promise<boolean> {
|
||||
return await promisify(exec)(command)
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user