mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Releasing kubeconfig file after lock
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
c9bf212153
commit
fe12fde589
@ -26,12 +26,13 @@ import * as lockFile from "proper-lockfile";
|
|||||||
import YAML from "json-to-pretty-yaml";
|
import YAML from "json-to-pretty-yaml";
|
||||||
|
|
||||||
export async function saveKubeconfig(config: KubeConfig, path: string) {
|
export async function saveKubeconfig(config: KubeConfig, path: string) {
|
||||||
lockFile.lock(path).then(async () => {
|
lockFile.lock(path).then(async (release) => {
|
||||||
const tmpFilePath = tempy.file();
|
const tmpFilePath = tempy.file();
|
||||||
const contents = YAML.stringify(JSON.parse(config.exportConfig()));
|
const contents = YAML.stringify(JSON.parse(config.exportConfig()));
|
||||||
|
|
||||||
await fs.promises.writeFile(tmpFilePath, contents);
|
await fs.promises.writeFile(tmpFilePath, contents);
|
||||||
await fs.promises.rename(tmpFilePath, path);
|
await fs.promises.rename(tmpFilePath, path);
|
||||||
|
release();
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
throw new Error(`Failed to aquire lock file.\n${e}`);
|
throw new Error(`Failed to aquire lock file.\n${e}`);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user