/
deviceManager.ts
47 lines (39 loc) 路 1.38 KB
/
deviceManager.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import {
fsExistsSync,
getRealPath,
logDefault,
inquirerPrompt,
getDirectories,
getContext,
executeAsync,
ExecOptionsPresets,
} from '@rnv/core';
import path from 'path';
export const launchKaiOSSimulator = async (target: string | boolean) => {
const c = getContext();
logDefault(`launchKaiOSSimulator: ${target}`);
const kaiosSdkPath = getRealPath(c.buildConfig?.sdks?.KAIOS_SDK);
if (!kaiosSdkPath) {
return Promise.reject(`c.buildConfig.sdks.KAIOS_SDK undefined`);
}
if (target === true) {
const availableSimulatorVersions = getDirectories(kaiosSdkPath).filter(
(directory) => directory.toLowerCase().indexOf('kaios') !== -1
);
const { selectedSimulator } = await inquirerPrompt({
name: 'selectedSimulator',
type: 'list',
message: 'What simulator would you like to launch?',
choices: availableSimulatorVersions,
});
target = selectedSimulator;
}
const simulatorPath = path.join(kaiosSdkPath, `${target}/kaiosrt/kaiosrt`);
if (simulatorPath && !fsExistsSync(simulatorPath)) {
return Promise.reject(`Can't find simulator at path: ${simulatorPath}`);
}
await executeAsync(simulatorPath, {
cwd: `${kaiosSdkPath}/${target}/kaiosrt`,
...ExecOptionsPresets.NO_SPINNER_FULL_ERROR_SUMMARY,
});
};