Compare commits
2 Commits
master
...
62ae2990a6
Author | SHA1 | Date | |
---|---|---|---|
62ae2990a6 | |||
f372e1ea17 |
20
AppTest.js
20
AppTest.js
@ -20,18 +20,20 @@ const {
|
||||
} = require ('./dist/lib/index.js');
|
||||
|
||||
(async () => {
|
||||
const str = await new StringOption ({ name: 'str' })
|
||||
.parse ();
|
||||
const bool = await new BooleanOption ({ name: 'bool' })
|
||||
.parse ();
|
||||
const num = await new NumberOption ({ name: 'num' })
|
||||
.parse ();
|
||||
const arr = await new ArrayOption ({ name: 'arr' })
|
||||
.parse ();
|
||||
/*
|
||||
* const str = await new StringOption ({ name: 'str' })
|
||||
*.parse ();
|
||||
*const bool = await new BooleanOption ({ name: 'bool' })
|
||||
*.parse ();
|
||||
*const num = await new NumberOption ({ name: 'num' })
|
||||
*.parse ();
|
||||
*const arr = await new ArrayOption ({ name: 'arr' })
|
||||
*.parse ();
|
||||
*/
|
||||
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'
|
||||
])
|
||||
}
|
||||
|
34
lib/Sources/Interactive/PathCustomPrompt.ts
Normal file
34
lib/Sources/Interactive/PathCustomPrompt.ts
Normal file
@ -0,0 +1,34 @@
|
||||
/* eslint-disable no-sync */
|
||||
import { dirname, join, sep, basename } from 'path';
|
||||
import fs from 'fs-extra';
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
interface PathPromptOptions {
|
||||
starting_dir?: string;
|
||||
folders_only?: boolean;
|
||||
}
|
||||
|
||||
export class PathPrompt {
|
||||
private _options: PathPromptOptions;
|
||||
|
||||
public constructor (options:PathPromptOptions) {
|
||||
this._options = options;
|
||||
}
|
||||
}
|
24
lib/Sources/Interactive/PathSubSource.ts
Normal file
24
lib/Sources/Interactive/PathSubSource.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { InteractiveSubSource } from './InteractiveSubSource';
|
||||
import { PathPrompt } from './PathCustomPrompt';
|
||||
|
||||
export class PathSubSource extends InteractiveSubSource {
|
||||
protected condition ():boolean {
|
||||
return [
|
||||
'path',
|
||||
'file',
|
||||
'folder'
|
||||
].includes (this.val.type_validation.option_type);
|
||||
}
|
||||
|
||||
protected async run (): Promise<void> {
|
||||
await this.val.assign_arg (
|
||||
this.opt,
|
||||
await new PathPrompt ({
|
||||
message: this.get_message (),
|
||||
default: this.opt.default,
|
||||
folder_only: this.val.type_validation.option_type === 'folder'
|
||||
})
|
||||
.run ()
|
||||
);
|
||||
}
|
||||
}
|
@ -2,10 +2,12 @@ import { ArraySubSource } from './ArraySubSource';
|
||||
import { BooleanSubSource } from './BooleanSubSource';
|
||||
import { PresetSubSource } from './PresetSubSource';
|
||||
import { StringSubSource } from './StringSubSource';
|
||||
import { PathSubSource } from './PathSubSource';
|
||||
|
||||
export const sources = [
|
||||
ArraySubSource,
|
||||
BooleanSubSource,
|
||||
PresetSubSource,
|
||||
PathSubSource,
|
||||
StringSubSource
|
||||
];
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"target": "es6",
|
||||
"module": "commonjs",
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./",
|
||||
|
Reference in New Issue
Block a user