From cc4c722707fa140fc243950f9f4720b251182aa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Legan=C3=A9s-Combarro?= Date: Sun, 22 Apr 2018 13:52:33 +0200 Subject: [PATCH 1/2] Support for scoped templates Add support for templates published as scoped packages. Partially fixes #18973. --- local-cli/generator/templates.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/local-cli/generator/templates.js b/local-cli/generator/templates.js index 54a09613b2b0cf..9f6380d0a0953a 100644 --- a/local-cli/generator/templates.js +++ b/local-cli/generator/templates.js @@ -75,7 +75,13 @@ function createFromRemoteTemplate( templateName = template.substr(template.lastIndexOf('/') + 1); } else { // e.g 'demo' - installPackage = 'react-native-template-' + template; + let scope = '' + if(template[0] === '@' && template.length > 3 && template.includes('/', 2)) { + [scope, ...template] = template.split('/') + scope += '/' + template = template.join('/') + } + installPackage = `${scope}react-native-template-${template}`; templateName = installPackage; } From 3dbd1a522321391409200aea5ddcd9ada7ce6645 Mon Sep 17 00:00:00 2001 From: Sean Scally Date: Wed, 10 Oct 2018 11:32:10 -0700 Subject: [PATCH 2/2] Fix linting issues --- local-cli/generator/templates.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/local-cli/generator/templates.js b/local-cli/generator/templates.js index 9f6380d0a0953a..4d880d1bc8445b 100644 --- a/local-cli/generator/templates.js +++ b/local-cli/generator/templates.js @@ -75,11 +75,15 @@ function createFromRemoteTemplate( templateName = template.substr(template.lastIndexOf('/') + 1); } else { // e.g 'demo' - let scope = '' - if(template[0] === '@' && template.length > 3 && template.includes('/', 2)) { - [scope, ...template] = template.split('/') - scope += '/' - template = template.join('/') + let scope = ''; + if ( + template[0] === '@' && + template.length > 3 && + template.includes('/', 2) + ) { + [scope, ...template] = template.split('/'); + scope += '/'; + template = template.join('/'); } installPackage = `${scope}react-native-template-${template}`; templateName = installPackage;