All files / src/commands init.ts

80% Statements 12/15
50% Branches 2/4
50% Functions 1/2
80% Lines 12/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 381x 1x 1x 1x   1x 2x 2x 1x                         1x     2x 2x                   2x    
import getIntegrations from '../utils/getIntegrations';
import inquirer from 'inquirer';
import createProject from '../scripts/createProject';
import path from 'path';
 
export default async (args) => {
  let projectName = args[0];
  if (!projectName) {
    const { typedProjectName } = await inquirer.prompt([
      {
        type: 'input',
        name: 'typedProjectName',
        message: 'What\'s your project name?',
        validate (value) {
          if (value.trim().length > 0) {
            return true;
          }
          return 'Please provide longer name';
        }
      }
    ]);
    projectName = typedProjectName;
  }
 
  const integrations = getIntegrations();
  const { chosenIntegration } = await inquirer
    .prompt([
      {
        type: 'list',
        name: 'chosenIntegration',
        message: 'Choose integration',
        choices: integrations
      }
    ]);
 
  return createProject(chosenIntegration, path.resolve(process.cwd(), projectName));
};