-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathdefault.js
43 lines (41 loc) · 1.14 KB
/
default.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import inquirer from 'inquirer'
import inquirerFileTreeSelection from 'inquirer-file-tree-selection-prompt'
import path from 'path';
import chalk from 'chalk';
import * as url from 'node:url';
const __filename = url.fileURLToPath(import.meta.url);
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
inquirer.registerPrompt('file-tree-selection', inquirerFileTreeSelection)
inquirer
.prompt([
{
type: 'file-tree-selection',
name: 'file',
default: __filename,
message: 'choose a file',
transformer: (input) => {
const name = input.split(path.sep).pop();
if (name[0] == ".") {
return chalk.grey(name);
}
return name;
}
},
{
type: 'file-tree-selection',
name: 'files',
default: [__filename],
multiple: true,
message: 'choose mutiple file',
transformer: (input) => {
const name = input.split(path.sep).pop();
if (name[0] == ".") {
return chalk.grey(name);
}
return name;
}
}
])
.then(answers => {
console.log(JSON.stringify(answers))
});