withexeditorhost
Advanced tools
Comparing version
@@ -24,3 +24,3 @@ /** | ||
export const parseCommand = args => { | ||
const reg = /^(?:(?:--)?help|-[h|v]|--version|s(?:etup)?)$/; | ||
const reg = /^(?:(?:--)?help|-[hv]|--version|s(?:etup)?)$/; | ||
if (Array.isArray(args) && args.some(arg => reg.test(arg))) { | ||
@@ -27,0 +27,0 @@ commander.exitOverride(); |
@@ -34,10 +34,32 @@ /** | ||
* @param {string} msg - message | ||
* @param {number} [code] - exit code | ||
* @returns {void} | ||
*/ | ||
export const abortSetup = msg => { | ||
export const abortSetup = (msg, code) => { | ||
setupOpts.clear(); | ||
console.info(`Setup aborted: ${msg}`); | ||
process.exit(); | ||
if (!Number.isInteger(code)) { | ||
code = 1; | ||
} | ||
process.exit(code); | ||
}; | ||
/** | ||
* handle inquirer error | ||
* @param {object} e - Error | ||
* @throws | ||
* @returns {Function} - abortSetup | ||
*/ | ||
export const handleInquirerError = e => { | ||
if (e instanceof Error) { | ||
let code = 1; | ||
if (e.name === 'ExitPromptError') { | ||
code = 130; | ||
} | ||
return abortSetup(e.message, code); | ||
} | ||
return abortSetup('Unknown error.', 1); | ||
}; | ||
/** | ||
* handle editor cmd args input | ||
@@ -55,7 +77,7 @@ * @param {Array} editorArgs - editor cmd args | ||
default: false | ||
}); | ||
}).catch(handleInquirerError); | ||
if (useCmdArgs) { | ||
const ans = await inquirer.input({ | ||
message: 'Input command line options:' | ||
}); | ||
}).catch(handleInquirerError); | ||
if (ans) { | ||
@@ -83,3 +105,3 @@ cmdArgs = new CmdArgs(ans.trim()).toArray(); | ||
required: true | ||
}); | ||
}).catch(handleInquirerError); | ||
} | ||
@@ -150,7 +172,7 @@ let parsedPath = editorFilePath; | ||
default: false | ||
}); | ||
}).catch(handleInquirerError); | ||
if (ans) { | ||
func = createEditorConfig(); | ||
} else { | ||
func = abortSetup(`${file} already exists.`); | ||
func = abortSetup(`${file} already exists.`, 1); | ||
} | ||
@@ -157,0 +179,0 @@ return func; |
// Generated by genversion. | ||
export const version = '8.1.1'; | ||
export const version = '8.1.2'; |
@@ -16,27 +16,32 @@ { | ||
"type": "module", | ||
"main": "./index.js", | ||
"exports": { | ||
"default": "./index.js" | ||
}, | ||
"dependencies": { | ||
"@inquirer/prompts": "^7.0.1", | ||
"commander": "^12.1.0", | ||
"semver-parser": "^4.1.6", | ||
"undici": "^6.20.1", | ||
"web-ext-native-msg": "^8.0.4" | ||
"@inquirer/prompts": "^7.2.3", | ||
"commander": "^13.1.0", | ||
"semver-parser": "^4.1.7", | ||
"undici": "^7.2.3", | ||
"web-ext-native-msg": "^8.0.6" | ||
}, | ||
"devDependencies": { | ||
"boxednode": "^2.4.4", | ||
"c8": "^10.1.2", | ||
"c8": "^10.1.3", | ||
"chai": "^5.1.2", | ||
"esbuild": "^0.24.0", | ||
"eslint": "^9.13.0", | ||
"eslint-plugin-import-x": "^4.4.0", | ||
"eslint-plugin-jsdoc": "^50.4.3", | ||
"eslint-plugin-regexp": "^2.6.0", | ||
"eslint-plugin-unicorn": "^56.0.0", | ||
"esbuild": "^0.24.2", | ||
"eslint": "^9.18.0", | ||
"eslint-plugin-import-x": "^4.6.1", | ||
"eslint-plugin-jsdoc": "^50.6.2", | ||
"eslint-plugin-regexp": "^2.7.0", | ||
"eslint-plugin-unicorn": "^56.0.1", | ||
"genversion": "^3.2.0", | ||
"globals": "^15.11.0", | ||
"globals": "^15.14.0", | ||
"jszip-cli": "^1.4.24", | ||
"mocha": "^10.8.1", | ||
"neostandard": "^0.11.7", | ||
"mocha": "^11.0.1", | ||
"neostandard": "^0.12.0", | ||
"sinon": "^19.0.2" | ||
}, | ||
"overrides": { | ||
"glob": "^10.4.5" | ||
}, | ||
"scripts": { | ||
@@ -53,3 +58,3 @@ "bundle-js": "esbuild --platform=node --outdir=./bundle --bundle --minify ./index.js", | ||
}, | ||
"version": "8.1.1" | ||
"version": "8.1.2" | ||
} |
60152
-1.03%11
-8.33%1198
-2.6%+ Added
+ Added
- Removed
- Removed
Updated
Updated
Updated
Updated
Updated