This commit is contained in:
2024-12-05 20:53:21 +08:00
parent a117281b9e
commit b631ff4a09
5 changed files with 74 additions and 11 deletions

View File

@@ -146,14 +146,27 @@ const setCommand = new Command('set')
when: () => value === 'not_input',
},
]);
if (answer.value === 'not_input') {
if (value === 'not_input' && !answer.value) {
value = '';
}
value = answer.value || value;
if (key === 'workdir') {
await setWorkdir({ workdir: value });
return;
}
const transformValue = (value: string) => {
if (value === 'true') {
return true;
}
if (value === 'false') {
return false;
}
// 如果是数字
if (!isNaN(Number(value))) {
return Number(value);
}
return value;
};
const newValue = transformValue(value);
if (key && value) {
flag = true;
if (key === 'dev') {
@@ -166,9 +179,6 @@ const setCommand = new Command('set')
config[key] = value;
}
console.log(chalk.green(`set ${key} success:`, config.key));
} else if (key) {
flag = true;
delete config[key];
}
if (flag) {
writeConfig(config);