Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions src/services/emulator/_runner.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,24 @@ import {createDeployTargetDir} from './_fs.services';
export const startContainer = async () => {
await assertAndInitConfig();

const parsedResult = await readEmulatorConfig();

if (!parsedResult.success) {
return;
}

const {config} = parsedResult;

const {valid} =
config.derivedConfig.runner === 'docker' ? await checkDockerVersion() : {valid: true};
const fn: RunWithConfigFn = async (args) => {
await startEmulator(args);
};

if (valid === 'error' || !valid) {
return;
}
await runWithConfig({fn});
};

await assertContainerRunnerRunning({runner: config.derivedConfig.runner});
export const stopContainer = async () => {
const fn: RunWithConfigFn = async (args) => {
await stopEmulator(args);
};

await startEmulator({config});
await runWithConfig({fn});
};

export const stopContainer = async () => {
type RunWithConfigFn = (params: {config: CliEmulatorConfig}) => Promise<void>;

const runWithConfig = async ({fn}: {fn: RunWithConfigFn}) => {
const parsedResult = await readEmulatorConfig();

if (!parsedResult.success) {
Expand All @@ -69,7 +66,7 @@ export const stopContainer = async () => {

await assertContainerRunnerRunning({runner: config.derivedConfig.runner});

await stopEmulator({config});
await fn({config});
};

const promptEmulatorType = async (): Promise<{emulatorType: Exclude<EmulatorType, 'console'>}> => {
Expand Down