multiple.js 772 B

12345678910111213141516171819202122232425262728293031
  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. root: '..',
  10. type: 'file-tree-selection',
  11. name: 'files',
  12. message: 'choose files',
  13. multiple: true,
  14. validate: (input) => {
  15. const name = input.split(path.sep).pop();
  16. return name[0] !== '.';
  17. },
  18. transformer: (input) => {
  19. const name = input.split(path.sep).pop();
  20. if (name[0] == ".") {
  21. return chalk.grey(name);
  22. }
  23. return name;
  24. }
  25. }
  26. ])
  27. .then(answers => {
  28. console.log(JSON.stringify(answers))
  29. });