Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
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()]
]
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()]
];
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)
}