feat(v2): allow init project via npm (#3729)

* feat(v2: allow init project via npm

* Add test-website to workspace

* Remove test-website from workspace

* Refactor
This commit is contained in:
Alexey Pyltsyn 2020-11-16 18:11:16 +03:00 committed by GitHub
parent d05d703dad
commit 5f20200661
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 5 deletions

View file

@ -38,9 +38,10 @@ program
program
.command('init [siteName] [template] [rootDir]')
.option('--use-npm')
.description('Initialize website')
.action((siteName, template, rootDir = '.') => {
wrapCommand(init)(path.resolve(rootDir), siteName, template);
.action((siteName, template, rootDir = '.', {useNpm}) => {
wrapCommand(init)(path.resolve(rootDir), siteName, template, {useNpm});
});
program.arguments('<command>').action((cmd) => {

View file

@ -41,8 +41,11 @@ export default async function init(
rootDir: string,
siteName?: string,
reqTemplate?: string,
cliOptions: Partial<{
useNpm: boolean;
}> = {},
): Promise<void> {
const useYarn = hasYarn();
const useYarn = !cliOptions.useNpm ? hasYarn() : false;
const templatesDir = path.resolve(__dirname, '../templates');
const templates = fs
.readdirSync(templatesDir)