mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Using async form without promises
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
76b99cdd87
commit
3c8c45cbaa
@ -29,14 +29,15 @@ import { noop } from "../../utils";
|
||||
export async function saveKubeconfig(config: KubeConfig, path: string) {
|
||||
const tmpFilePath = tempy.file();
|
||||
|
||||
lockFile.lock(path).then(async (release) => {
|
||||
try {
|
||||
const release = await lockFile.lock(path);
|
||||
const contents = YAML.stringify(JSON.parse(config.exportConfig()));
|
||||
|
||||
await fs.promises.writeFile(tmpFilePath, contents);
|
||||
await fs.promises.rename(tmpFilePath, path);
|
||||
release();
|
||||
}).catch(async (e) => {
|
||||
} catch (e) {
|
||||
await fs.unlink(tmpFilePath, noop);
|
||||
throw new Error(`Failed to acquire lock file.\n${e}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user