Skip to content

Commit 2f77617

Browse files
Sajohaewanharris
authored andcommitted
[ALOY-1652] CLI: Improve handling of missing directories and files in alloy new (#925)
https://jira.appcelerator.org/browse/ALOY-1652
1 parent 335c645 commit 2f77617

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Alloy/commands/new/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,12 @@ function getPaths(project, templateName, testapp) {
138138
var template = path.join(alloy, 'template');
139139
var projectTemplates = path.join(alloy, '..', 'templates');
140140
var customTemplateDir;
141+
var customAppDir;
141142
var readMeFile;
142143

143144
if (fs.existsSync(templateName) && !testapp) {
144145
customTemplateDir = templateName;
146+
customAppDir = path.join(templateName, 'app');
145147
readMeFile = path.join(customTemplateDir, 'README');
146148
}
147149

@@ -150,6 +152,7 @@ function getPaths(project, templateName, testapp) {
150152
alloy: alloy,
151153
template: path.join(alloy, 'template'),
152154
readme: fs.existsSync(readMeFile) ? readMeFile : path.join(template, 'README'),
155+
appTemplate: (!testapp) ? customAppDir || path.join(projectTemplates, templateName, 'app') : path.join(sampleAppsDir, testapp),
153156
projectTemplate: (!testapp) ? customTemplateDir || path.join(projectTemplates, templateName) : path.join(sampleAppsDir, testapp),
154157

155158
// project paths
@@ -167,8 +170,12 @@ function getPaths(project, templateName, testapp) {
167170
// skip
168171
return;
169172
case 'projectTemplate':
170-
var error = (!testapp) ? 'Project template "' + templateName : 'Test app "' + testapp;
171-
errs.push(error + '" not found at "' + v + '"');
173+
var projError = (!testapp) ? 'Project template "' + templateName : 'Test app "' + testapp;
174+
errs.push(projError + '" not found at "' + v + '"');
175+
break;
176+
case 'appTemplate':
177+
var appError = (!testapp) ? 'Application template "' + v : 'Test app "' + testapp;
178+
errs.push(appError + '" not found');
172179
break;
173180
case 'project':
174181
errs.push('Project path not found at "' + v + '"');

0 commit comments

Comments
 (0)