mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-01-12 22:46:30 +08:00
Support scoped templates (#7991)
This commit is contained in:
committed by
Brody McKee
parent
58b4738a49
commit
e7cdde6ab8
@@ -647,11 +647,17 @@ function getTemplateInstallPackage(template, originalDirectory) {
|
||||
) {
|
||||
// for tar.gz or alternative paths
|
||||
templateToInstall = template;
|
||||
} else if (template.startsWith(templateToInstall)) {
|
||||
templateToInstall = template;
|
||||
} else if (!template.startsWith(templateToInstall)) {
|
||||
// Add prefix `cra-template` to non-prefixed templates.
|
||||
templateToInstall += `-${template}`;
|
||||
} else {
|
||||
// Add prefix 'cra-template-' to non-prefixed templates, leaving any
|
||||
// @scope/ intact.
|
||||
const packageMatch = template.match(/^(@[^/]+\/)?(.+)$/);
|
||||
const scope = packageMatch[1] || '';
|
||||
const templateName = packageMatch[2];
|
||||
|
||||
const name = templateName.startsWith(templateToInstall)
|
||||
? templateName
|
||||
: `${templateToInstall}-${templateName}`;
|
||||
templateToInstall = `${scope}${name}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user