improve env_loc.js to able to convert relative paths entered by users to absolute paths

This commit is contained in:
jtl959
2026-08-19 18:35:48 +08:00
parent 7c0b295cd6
commit 4645729e64
3 changed files with 6 additions and 8 deletions

0
.prettierrc.js Executable file → Normal file
View File

View File

@@ -37,8 +37,6 @@ const existingEnv = fs.existsSync('./env_loc.gitomit.sfomit.json') ? require(pat
const baseEnv = Object.assign({}, paramDefaults, defaultEnv, existingEnv)
const isEmptyValue = (value) => value === '' || value === undefined || value === null
const askKeyValues = (keys) =>
new Promise((resolve) => {
if (!keys.length || !process.stdin.isTTY) {
@@ -61,8 +59,8 @@ const askKeyValues = (keys) =>
}
const key = keys[index]
rl.question(`Input value for "${key}" (Enter to keep empty): `, (answer) => {
values[key] = answer === '' ? '' : answer
rl.question(`[${index}] ${key}: "${baseEnv[key]||''}"\n >> `, (answer) => {
if (answer !== '') values[key] = path.resolve(answer)
index += 1
askNext()
})
@@ -72,14 +70,14 @@ const askKeyValues = (keys) =>
})
const main = async () => {
const keysToPrompt = Object.keys(baseEnv).filter((key) => isEmptyValue(baseEnv[key]))
const inputValues = await askKeyValues(keysToPrompt)
console.log('\n::*** Configuring local environment. \nEnter new values or keep blank for no change:\n')
const inputValues = await askKeyValues(Object.keys(baseEnv))
const localEnv = Object.assign({}, baseEnv, inputValues)
fs.writeFileSync(path.resolve('./env_loc.gitomit.sfomit.json'), JSON.stringify(localEnv, null, 2), 'utf8')
console.log('\n::*** Configuring local enviroment:')
console.log(localEnv)
console.log('\n::*** Configured local enviroment:')
console.log(localEnv, '\n')
}
if (require.main === module) {

0
gitignore_merge.sh Executable file → Normal file
View File