Browse Source

add parameter for templates (#13410)

pull/13412/head
Muhammed Altuğ 4 years ago
committed by GitHub
parent
commit
5cc6928a60
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      npm/ng-packs/scripts/copy-packages-to-templates.ts

12
npm/ng-packs/scripts/copy-packages-to-templates.ts

@ -1,8 +1,10 @@
import execa from 'execa'; import execa from 'execa';
import fse from 'fs-extra'; import fse from 'fs-extra';
import fs from 'fs'; import fs from 'fs';
import program from 'commander';
const templates = ['app', 'app-nolayers', 'module']; const defaultTemplates = ['app', 'app-nolayers', 'module'];
const defaultTemplatePath = '../../../templates';
const packageMap = { const packageMap = {
account: 'ng.account', account: 'ng.account',
'account-core': 'ng.account.core', 'account-core': 'ng.account.core',
@ -16,7 +18,11 @@ const packageMap = {
'theme-basic': 'ng.theme.basic', 'theme-basic': 'ng.theme.basic',
'theme-shared': 'ng.theme.shared', 'theme-shared': 'ng.theme.shared',
}; };
program.option('-t, --templates <templates>', 'template dirs', false);
program.option('-p, --template-path <templatePath>', 'root template path', false);
program.parse(process.argv);
const templates = program.templates ? program.templates.split(',') : defaultTemplates;
const templateRootPath = program.templatePath ? program.templatePath : defaultTemplatePath;
(async () => { (async () => {
await execa('yarn', ['build'], { await execa('yarn', ['build'], {
stdout: 'inherit', stdout: 'inherit',
@ -33,7 +39,7 @@ async function runEachTemplate(
handler: (template: string, templatePath?: string) => void | Promise<any>, handler: (template: string, templatePath?: string) => void | Promise<any>,
) { ) {
for (var template of templates) { for (var template of templates) {
const templatePath = `../../../templates/${template}/angular`; const templatePath = `${templateRootPath}/${template}/angular`;
const result = handler(template, templatePath); const result = handler(template, templatePath);
result instanceof Promise ? await result : result; result instanceof Promise ? await result : result;
} }

Loading…
Cancel
Save