Skip to content

Commit

Permalink
Remove useless IIFEs
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Dubois <[email protected]>
  • Loading branch information
jandubois committed Mar 11, 2023
1 parent 54ce4fa commit 9a0bd22
Showing 1 changed file with 18 additions and 24 deletions.
42 changes: 18 additions & 24 deletions pkg/rancher-desktop/backend/lima.ts
Original file line number Diff line number Diff line change
Expand Up @@ -755,18 +755,16 @@ export default class LimaBackend extends events.EventEmitter implements VMBacken
}

protected getLimaConfig(): Promise<LimaConfiguration | undefined> {
return (async() => {
try {
const configPath = path.join(paths.lima, MACHINE_NAME, 'lima.yaml');
const configRaw = await fs.promises.readFile(configPath, 'utf-8');
try {
const configPath = path.join(paths.lima, MACHINE_NAME, 'lima.yaml');
const configRaw = await fs.promises.readFile(configPath, 'utf-8');

return yaml.parse(configRaw) as LimaConfiguration;
} catch (ex) {
if ((ex as NodeJS.ErrnoException).code === 'ENOENT') {
return undefined;
}
return yaml.parse(configRaw) as LimaConfiguration;
} catch (ex) {
if ((ex as NodeJS.ErrnoException).code === 'ENOENT') {
return undefined;
}
})();
}
}

protected static get limactl() {
Expand Down Expand Up @@ -957,25 +955,21 @@ export default class LimaBackend extends events.EventEmitter implements VMBacken
}

protected imageInfo(fileName: string): Promise<QEMUImageInfo> {
return (async() => {
try {
const { stdout } = await this.spawnWithCapture(LimaBackend.qemuImg, 'info', '--output=json', '--force-share', fileName);
try {
const { stdout } = await this.spawnWithCapture(LimaBackend.qemuImg, 'info', '--output=json', '--force-share', fileName);

return JSON.parse(stdout) as QEMUImageInfo;
} catch {
return { format: 'unknown' } as QEMUImageInfo;
}
})();
return JSON.parse(stdout) as QEMUImageInfo;
} catch {
return { format: 'unknown' } as QEMUImageInfo;
}
}

protected convertToRaw(fileName: string): Promise<void> {
return (async() => {
const rawFileName = `${ fileName }.raw`;
const rawFileName = `${ fileName }.raw`;

await this.spawnWithCapture(LimaBackend.qemuImg, 'convert', fileName, rawFileName);
await fs.promises.unlink(fileName);
await fs.promises.rename(rawFileName, fileName);
})();
await this.spawnWithCapture(LimaBackend.qemuImg, 'convert', fileName, rawFileName);
await fs.promises.unlink(fileName);
await fs.promises.rename(rawFileName, fileName);
}

protected get isRegistered(): Promise<boolean> {
Expand Down

0 comments on commit 9a0bd22

Please sign in to comment.