mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
chore(cloudcmd) add choose
This commit is contained in:
parent
f1310f303f
commit
076077223a
2 changed files with 17 additions and 3 deletions
|
|
@ -9,6 +9,13 @@ const exit = require(DIR_SERVER + 'exit');
|
|||
const config = require(DIR_SERVER + 'config');
|
||||
const env = require(DIR_SERVER + 'env');
|
||||
|
||||
const choose = (a, b) => {
|
||||
if (!a && typeof a !== 'boolean')
|
||||
return b;
|
||||
|
||||
return a;
|
||||
};
|
||||
|
||||
const argv = process.argv;
|
||||
const args = require('minimist')(argv.slice(2), {
|
||||
string: [
|
||||
|
|
@ -52,10 +59,10 @@ const args = require('minimist')(argv.slice(2), {
|
|||
prefix : config('prefix') || '',
|
||||
progress : config('progress'),
|
||||
console : config('console'),
|
||||
terminal : env.bool('terminal') || config('terminal'),
|
||||
terminal : choose(env.bool('terminal'), config('terminal')),
|
||||
|
||||
'terminal-path': env('terminal_path') || config('terminalPath'),
|
||||
'config-dialog': env.bool('config_dialog') || config('configDialog'),
|
||||
'config-dialog': choose(env.bool('config_dialog'), config('configDialog')),
|
||||
'one-panel-mode': config('onePanelMode'),
|
||||
'html-dialogs': config('htmlDialogs')
|
||||
},
|
||||
|
|
|
|||
|
|
@ -4,7 +4,14 @@ const env = process.env;
|
|||
const up = (a) => a.toUpperCase();
|
||||
|
||||
module.exports = parse;
|
||||
module.exports.bool = (name) => Boolean(parse(name));
|
||||
module.exports.bool = (name) => {
|
||||
const value = parse(name);
|
||||
|
||||
if (value === 'false')
|
||||
return false;
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
function parse(name) {
|
||||
const small = `cloudcmd_${name}`;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue