fix
This commit is contained in:
parent
5dfdb39af6
commit
8eaa02d96f
@ -19,7 +19,11 @@ const { InteractiveOptions } = require ('./dist/lib/index.js');
|
||||
{ name: 'num', type: 'number', env: 'TEST_NUM' },
|
||||
{ name: 'arr', type: 'array', env: 'TEST_ARR' },
|
||||
{ name: 'fld', type: 'folder', env: 'TEST_FOLDER' }
|
||||
], { exit_on_interrupt: true, configs: [ 'test.json' ] });
|
||||
], {
|
||||
exit_on_interrupt: true,
|
||||
configs: [ 'test.json' ],
|
||||
error_callback: console.log
|
||||
});
|
||||
await reader.parse ();
|
||||
console.log (reader.serialize (true));
|
||||
}) ();
|
||||
|
@ -75,8 +75,8 @@ export class InteractiveOptions extends Persistent {
|
||||
&& Array.isArray (source_config.configs)
|
||||
) {
|
||||
this.sources.push (new ConfigSource (
|
||||
source_config.error_callback,
|
||||
source_config.configs
|
||||
source_config.configs,
|
||||
source_config.error_callback
|
||||
));
|
||||
}
|
||||
if (source_config.env !== false)
|
||||
@ -85,8 +85,8 @@ export class InteractiveOptions extends Persistent {
|
||||
this.sources.push (new ArgSource (source_config.error_callback));
|
||||
if (source_config.interactive !== false) {
|
||||
this.sources.push (new InteractiveSource (
|
||||
source_config.error_callback,
|
||||
exit_on_interrupt
|
||||
exit_on_interrupt,
|
||||
source_config.error_callback
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ import { OptionSource } from './OptionSource';
|
||||
export class ConfigSource extends OptionSource {
|
||||
private _config_files: string[];
|
||||
|
||||
public constructor (error_callback?:ErrorCallback, config_files: string[]) {
|
||||
public constructor (config_files: string[], error_callback?:ErrorCallback) {
|
||||
super (error_callback);
|
||||
this._config_files = config_files;
|
||||
}
|
||||
@ -55,7 +55,8 @@ export class ConfigSource extends OptionSource {
|
||||
data[key] = json[key];
|
||||
}
|
||||
catch (e) {
|
||||
this.error_callback ('*', `config file: ${f}`, e);
|
||||
if (typeof this.error_callback !== 'undefined')
|
||||
this.error_callback ('*', `config file: ${f}`, e);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -9,14 +9,15 @@
|
||||
/* eslint-disable no-process-exit */
|
||||
import { Confirm, Input, List, AutoComplete } from 'enquirer';
|
||||
import { OptionProcess, Option } from '../Option';
|
||||
import { ErrorCallback } from '../Types/ErrorCallback';
|
||||
import { OptionSource } from './OptionSource';
|
||||
|
||||
export class InteractiveSource extends OptionSource {
|
||||
private _exit_on_interrupt: boolean;
|
||||
|
||||
public constructor (
|
||||
error_callback?:ErrorCallback,
|
||||
exit_on_interrupt: boolean
|
||||
exit_on_interrupt: boolean,
|
||||
error_callback?:ErrorCallback
|
||||
) {
|
||||
super (error_callback);
|
||||
this._exit_on_interrupt = exit_on_interrupt;
|
||||
|
Loading…
x
Reference in New Issue
Block a user