prompt will have to be self made, or extending more basic levels of enquirer
This commit is contained in:
parent
f372e1ea17
commit
62ae2990a6
@ -33,7 +33,7 @@ const {
|
||||
const fld = await new FolderOption ({ name: 'fld' })
|
||||
.parse ();
|
||||
|
||||
const data = { str, bool, num, arr, fld };
|
||||
const data = { /* str, bool, num, arr,*/ fld };
|
||||
|
||||
console.log (data);
|
||||
}) ();
|
||||
|
2
Jenkinsfile
vendored
2
Jenkinsfile
vendored
@ -5,7 +5,7 @@ pipeline {
|
||||
VERSION = VersionNumber([
|
||||
versionNumberString:
|
||||
'${BUILDS_ALL_TIME}',
|
||||
versionPrefix: '2.0.',
|
||||
versionPrefix: '2.1.',
|
||||
worstResultForIncrement: 'SUCCESS'
|
||||
])
|
||||
}
|
||||
|
@ -17,10 +17,7 @@ export abstract class InteractiveSubSource {
|
||||
|
||||
public async parse ():Promise<boolean> {
|
||||
if (this.condition ()) {
|
||||
await this.run ()
|
||||
.catch ((e) => {
|
||||
console.log (e);
|
||||
});
|
||||
await this.run ();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -1,25 +1,34 @@
|
||||
import { Prompt } from 'enquirer';
|
||||
/* eslint-disable no-sync */
|
||||
import { dirname, join, sep, basename } from 'path';
|
||||
import fs from 'fs-extra';
|
||||
|
||||
export class PathPrompt extends Prompt {
|
||||
private _index = 0;
|
||||
private _value = '';
|
||||
|
||||
public constructor (options:Record<string, unknown> = {}) {
|
||||
super (options);
|
||||
function read_dir (dir:string, exclude_files:boolean):string[] {
|
||||
const contents = fs.readdirSync (dir);
|
||||
contents.unshift ('..');
|
||||
if (exclude_files) {
|
||||
return contents.filter ((c) => {
|
||||
const full_path = join (dir, c);
|
||||
try {
|
||||
return fs.statSync (full_path)
|
||||
.isDirectory ();
|
||||
}
|
||||
catch {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
return contents;
|
||||
}
|
||||
|
||||
public up (): void {
|
||||
this._index--;
|
||||
this.render ();
|
||||
}
|
||||
interface PathPromptOptions {
|
||||
starting_dir?: string;
|
||||
folders_only?: boolean;
|
||||
}
|
||||
|
||||
public down (): void {
|
||||
this._index++;
|
||||
this.render ();
|
||||
}
|
||||
export class PathPrompt {
|
||||
private _options: PathPromptOptions;
|
||||
|
||||
public render (): void {
|
||||
this.clear ();
|
||||
this.write (`${this.state.message}: ${this._value}`);
|
||||
public constructor (options:PathPromptOptions) {
|
||||
this._options = options;
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,9 @@ export class PathSubSource extends InteractiveSubSource {
|
||||
await this.val.assign_arg (
|
||||
this.opt,
|
||||
await new PathPrompt ({
|
||||
message: this.get_message (),
|
||||
default: this.opt.default
|
||||
message: this.get_message (),
|
||||
default: this.opt.default,
|
||||
folder_only: this.val.type_validation.option_type === 'folder'
|
||||
})
|
||||
.run ()
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user