How to use the clap.confirm function in clap

To help you get started, we’ve selected a few clap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github basisjs / basisjs-tools / lib / create / index.js View on Github external
//

  var target;
  var output = [];

  switch (topic)
  {
    case 'app':
    case 'module':
      target = topic == 'app' ? options.output : path.join(options.output, options.name);
      resolveDirPath(target);
      output = [target];

      // if folder exists and not empty - confirm possible file rewrite
      if (fs.readdirSync(target).length)
        clap.confirm('Destination folder is not empty, some files may be overwritten. Continue? (y/n) ', function(yes){
          if (yes)
          {
            console.log();
            mainTask();
          }
        });
      else
        mainTask();

      break;

    case 'type':
      options.instanceName = options.name.charAt(0).toLowerCase() + options.name.substr(1);
      target = options.output;
      output = [target];

clap

Command line argument parser

MIT
Latest version published 3 years ago

Package Health Score

50 / 100
Full package analysis

Popular clap functions