Skip to content

Commit 5cdad08

Browse files
committed
feat: support clearGlobalConfig
1 parent fb89c62 commit 5cdad08

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

packages/utils/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@serverless-devs/utils",
3-
"version": "0.0.17",
3+
"version": "0.0.18",
44
"description": "utils for serverless-devs",
55
"main": "lib/index.js",
66
"scripts": {

packages/utils/src/global-config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ export const getGlobalConfig = (key: string, fallback?: string) => {
1515
return content?.[key] || fallback;
1616
};
1717

18+
// TODO: 目前只更新了Serverless Devs的utils版本号
19+
export const clearGlobalConfig = (key: string) => {
20+
fs.writeFileSync(GLOBAL_CONFIG_FILE_PATH, yaml.dump({
21+
...getYamlContent(GLOBAL_CONFIG_FILE_PATH),
22+
[key]: undefined,
23+
}));
24+
};
25+
1826
export const setGlobalConfig = (key: string, value: unknown) => {
1927
// 创建 a 目录以及其子目录
2028
fs.mkdirSync(rootHome, { recursive: true });

packages/utils/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export { default as isCiCdEnvironment } from './is-cicd-environment';
66
export { default as isChinaUser } from './is-china-user';
77
export { default as isDebugMode } from './is-debug-mode';
88
export { default as getRootHome } from './get-root-home';
9-
export { setGlobalConfig, getGlobalConfig, GLOBAL_CONFIG_FILE_PATH } from './global-config';
9+
export { setGlobalConfig, getGlobalConfig, clearGlobalConfig, GLOBAL_CONFIG_FILE_PATH } from './global-config';
1010
export { default as parseArgv } from './parse-argv';
1111
export { default as getYamlContent, getYamlPath, getAbsolutePath } from './get-yaml-content';
1212
export { default as fieldEncryption } from './field-encryption';

0 commit comments

Comments
 (0)