How to use degit - 5 common examples

To help you get started, we’ve selected a few degit 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 Rich-Harris / degit / src / bin.js View on Github external
v: 'verbose'
	},
	boolean: ['force', 'cache', 'verbose']
});

const [src, dest = '.'] = args._;

if (args.help || !src) {
	const help = fs.readFileSync(path.join(__dirname, 'help.md'), 'utf-8')
		.replace(/^(\s*)#+ (.+)/gm, (m, s, _) => s + chalk.bold(_))
		.replace(/_([^_]+)_/g, (m, _) => chalk.underline(_))
		.replace(/`([^`]+)`/g, (m, _) => chalk.cyan(_));

	process.stdout.write(`\n${help}\n`);
} else {
	const d = degit(src, args);

	d.on('info', event => {
		console.error(chalk.cyan(`> ${event.message.replace('options.', '--')}`));
	});

	d.on('warn', event => {
		console.error(chalk.magenta(`! ${event.message.replace('options.', '--')}`));
	});

	d.clone(dest)
		// .then(() => {

		// })
		.catch(err => {
			console.error(chalk.red(`! ${err.message}`));
			process.exit(1);
github FullHuman / tosin / src / index.js View on Github external
name: 'repository',
      message: 'What is your repository (/)? (e.g. FullHuman/tosin)'
    },
    {
      type: 'input',
      name: 'developerName',
      message: 'What is your name (used for the licence)?'
    },
    {
      type: 'input',
      name: 'email',
      message: 'What is the email to be use for the code of conduct?'
    }
  ])
  // clone the template library
  const emitter = degit('FullHuman/tosin-template-library', {
    cache: false,
    force: true,
    verbose: false
  })

  await emitter.clone('.')

  const replaceSets = [
    ['{% project name %}', response.projectName],
    ['{% human project name %}', response.humanProjectName],
    ['{% developer name %}', response.developerName],
    ['{% email %}', response.email],
    ['{% repository %}', response.repository],
    ['{% lowercase repository %}', response.repository.toLowerCase()]
  ]
github FullHuman / tosin / lib / tosin.es.js View on Github external
name: 'repository',
      message: 'What is your repository (/)? (e.g. FullHuman/tosin)'
    },
    {
      type: 'input',
      name: 'developerName',
      message: 'What is your name (used for the licence)?'
    },
    {
      type: 'input',
      name: 'email',
      message: 'What is the email to be use for the code of conduct?'
    }
  ]);
  // clone the template library
  const emitter = degit('FullHuman/tosin-template-library', {
    cache: false,
    force: true,
    verbose: false
  });

  await emitter.clone('.');

  const replaceSets = [
    ['{% project name %}', response.projectName],
    ['{% human project name %}', response.humanProjectName],
    ['{% developer name %}', response.developerName],
    ['{% email %}', response.email],
    ['{% repository %}', response.repository],
    ['{% lowercase repository %}', response.repository.toLowerCase()]
  ];
github yuanqing / create-figma-plugin / packages / create-figma-plugin / src / clone-from-template.js View on Github external
export async function cloneFromTemplate (pluginDirectoryPath, template) {
  const templateDirectory = resolve(
    __dirname,
    '..',
    'plugin-templates',
    template
  )
  if ((await exists(templateDirectory)) === true) {
    await ensureDir(pluginDirectoryPath)
    return copy(templateDirectory, pluginDirectoryPath)
  }
  if (gitHubRepositoryRegex.test(template) === false) {
    return new Error('Invalid GitHub repository')
  }
  return degit(template).clone(pluginDirectoryPath)
}

degit

Straightforward project scaffolding

MIT
Latest version published 4 years ago

Package Health Score

64 / 100
Full package analysis

Popular degit functions