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' })
|
const fld = await new FolderOption ({ name: 'fld' })
|
||||||
.parse ();
|
.parse ();
|
||||||
|
|
||||||
const data = { str, bool, num, arr, fld };
|
const data = { /* str, bool, num, arr,*/ fld };
|
||||||
|
|
||||||
console.log (data);
|
console.log (data);
|
||||||
}) ();
|
}) ();
|
||||||
|
2
Jenkinsfile
vendored
2
Jenkinsfile
vendored
@ -5,7 +5,7 @@ pipeline {
|
|||||||
VERSION = VersionNumber([
|
VERSION = VersionNumber([
|
||||||
versionNumberString:
|
versionNumberString:
|
||||||
'${BUILDS_ALL_TIME}',
|
'${BUILDS_ALL_TIME}',
|
||||||
versionPrefix: '2.0.',
|
versionPrefix: '2.1.',
|
||||||
worstResultForIncrement: 'SUCCESS'
|
worstResultForIncrement: 'SUCCESS'
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
@ -17,10 +17,7 @@ export abstract class InteractiveSubSource {
|
|||||||
|
|
||||||
public async parse ():Promise<boolean> {
|
public async parse ():Promise<boolean> {
|
||||||
if (this.condition ()) {
|
if (this.condition ()) {
|
||||||
await this.run ()
|
await this.run ();
|
||||||
.catch ((e) => {
|
|
||||||
console.log (e);
|
|
||||||
});
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
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 {
|
function read_dir (dir:string, exclude_files:boolean):string[] {
|
||||||
private _index = 0;
|
const contents = fs.readdirSync (dir);
|
||||||
private _value = '';
|
contents.unshift ('..');
|
||||||
|
if (exclude_files) {
|
||||||
public constructor (options:Record<string, unknown> = {}) {
|
return contents.filter ((c) => {
|
||||||
super (options);
|
const full_path = join (dir, c);
|
||||||
|
try {
|
||||||
|
return fs.statSync (full_path)
|
||||||
|
.isDirectory ();
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
public up (): void {
|
interface PathPromptOptions {
|
||||||
this._index--;
|
starting_dir?: string;
|
||||||
this.render ();
|
folders_only?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
public down (): void {
|
export class PathPrompt {
|
||||||
this._index++;
|
private _options: PathPromptOptions;
|
||||||
this.render ();
|
|
||||||
}
|
|
||||||
|
|
||||||
public render (): void {
|
public constructor (options:PathPromptOptions) {
|
||||||
this.clear ();
|
this._options = options;
|
||||||
this.write (`${this.state.message}: ${this._value}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,8 @@ export class PathSubSource extends InteractiveSubSource {
|
|||||||
this.opt,
|
this.opt,
|
||||||
await new PathPrompt ({
|
await new PathPrompt ({
|
||||||
message: this.get_message (),
|
message: this.get_message (),
|
||||||
default: this.opt.default
|
default: this.opt.default,
|
||||||
|
folder_only: this.val.type_validation.option_type === 'folder'
|
||||||
})
|
})
|
||||||
.run ()
|
.run ()
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user