custom.js 668 B

1234567891011121314151617181920212223242526
  1. const inquirer = require('inquirer')
  2. const inquirerFileTreeSelection = require('../dist/index')
  3. const path = require('path');
  4. const chalk = require('chalk');
  5. inquirer.registerPrompt('file-tree-selection', inquirerFileTreeSelection)
  6. inquirer
  7. .prompt([
  8. {
  9. type: 'file-tree-selection',
  10. name: 'file',
  11. default: path.join(__dirname, './multiple.js'),
  12. message: 'choose a file',
  13. transformer: (input) => {
  14. const name = input.split(path.sep).pop();
  15. if (name[0] == ".") {
  16. return chalk.grey(name);
  17. }
  18. return name;
  19. },
  20. },
  21. ])
  22. .then(answers => {
  23. console.log(JSON.stringify(answers))
  24. });