mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
|
|
import fse from "fs-extra";
|
|
import path from "path";
|
|
import { getLegacyGlobalDiForExtensionApi } from "../../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
|
|
import directoryForUserDataInjectable
|
|
from "../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable";
|
|
|
|
export function fileNameMigration() {
|
|
const di = getLegacyGlobalDiForExtensionApi();
|
|
|
|
const userDataPath = di.inject(directoryForUserDataInjectable);
|
|
const configJsonPath = path.join(userDataPath, "config.json");
|
|
const lensUserStoreJsonPath = path.join(userDataPath, "lens-user-store.json");
|
|
|
|
try {
|
|
fse.moveSync(configJsonPath, lensUserStoreJsonPath);
|
|
} catch (error) {
|
|
if (error.code === "ENOENT" && error.path === configJsonPath) { // (No such file or directory)
|
|
return; // file already moved
|
|
} else if (error.message === "dest already exists.") {
|
|
fse.removeSync(configJsonPath);
|
|
} else {
|
|
// pass other errors along
|
|
throw error;
|
|
}
|
|
}
|
|
}
|