scripts/new.js
function addComponent(name) {
  const source = path.join(packages, '.template');
  const destination = path.join(packages, name);

  if (fs.existsSync(destination)) {
    console.log(chalk.red('error'), 'Component package exists');
  } else {
    ncp(source, destination, error => {
      if (error) {
        console.log(chalk.red('error'), error);
      } else {
        const items = walk(destination, { nodir: true });

        items.forEach(item => {
          const string = fs.readFileSync(item.path, 'utf8');
          const template = Handlebars.compile(string);
          const data = template({ component: name });

          fs.writeFileSync(item.path, data, 'utf8');
        });

        console.log(chalk.green('success'), 'Added new component');
        execSync('yarn postinstall');
        updateDemo(name);
      }
    });
  }
}
function addComponent(name) {
  const source = path.join(packages, '.template');
  const destination = path.join(packages, name);

  if (fs.existsSync(destination)) {
    console.log(chalk.red('error'), 'Component package exists');
  } else {
    ncp(source, destination, error => {
      if (error) {
        console.log(chalk.red('error'), error);
      } else {
        const items = walk(destination, { nodir: true });

        items.forEach(item => {
          const string = fs.readFileSync(item.path, 'utf8');
          const template = Handlebars.compile(string);
          const data = template({ component: name });

          fs.writeFileSync(item.path, data, 'utf8');
        });

        console.log(chalk.green('success'), 'Added new component');
        execSync('yarn postinstall');
        updateDemo(name);
      }
    });
  }
}
function addComponent ( name ) { const source = path . join ( packages , '.template' ) ; const destination = path . join ( packages , name ) ; if ( fs . existsSync ( destination ) ) { console . log ( chalk . red ( 'error' ) , 'Component package exists' ) ; } else { ncp ( source , destination , error => { if ( error ) { console . log ( chalk . red ( 'error' ) , error ) ; } else { const items = walk ( destination , { nodir : true } ) ; items . forEach ( item => { const string = fs . readFileSync ( item . path , 'utf8' ) ; const template = Handlebars . compile ( string ) ; const data = template ( { component : name } ) ; fs . writeFileSync ( item . path , data , 'utf8' ) ; } ) ; console . log ( chalk . green ( 'success' ) , 'Added new component' ) ; execSync ( 'yarn postinstall' ) ; updateDemo ( name ) ; } } ) ; } }
Add a new component package with the given name.

@param {String} name The name of the component to add.
Add a new component package with the given name .