Skip to content

Commit 95e93fc

Browse files
committed
Merge pull request tidev#666 from feons/ALOY-1238
[ALOY-1238] Can't re-create index controller after renaming original one
2 parents 0f9adf8 + 2d7562e commit 95e93fc

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

Alloy/commands/generate/generateUtils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ exports.generateMigrationFileName = function(t) {
2727
exports.generate = function(name, type, program, args) {
2828
args = args || {};
2929
var ext = '.'+CONST.FILE_EXT[type];
30-
var paths = U.getAndValidateProjectPaths(program.outputPath);
30+
var paths = U.getAndValidateProjectPaths(program.outputPath, {command : CONST.COMMANDS.GENERATE});
3131
var templatePath = path.join(alloyRoot,'template',type.toLowerCase()+ext);
3232
// ALOY-372 - Support 'alloy generate' command for widget components
3333
var widgetPath = (program.widgetname) ? CONST.DIR['WIDGET']+path.sep+program.widgetname : '';

Alloy/commands/generate/index.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ function generate(args, program) {
2222
}
2323

2424
// make sure we have a valid project path
25-
var paths = U.getAndValidateProjectPaths(program.projectDir || program.outputPath || process.cwd());
25+
var paths = U.getAndValidateProjectPaths(
26+
program.projectDir || program.outputPath || process.cwd(),
27+
{command : CONST.COMMANDS.GENERATE}
28+
);
2629
program.projectDir = program.outputPath = paths.project;
2730

2831
// grab the name
@@ -43,4 +46,4 @@ function generate(args, program) {
4346
(require('./targets/' + target))(name, args.slice(2), program);
4447
}
4548

46-
module.exports = generate;
49+
module.exports = generate;

Alloy/common/constants.js

+4
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,7 @@ exports.SPECIAL_PROPERTY_NAMES = [
235235
'onCreateOptionsMenu',
236236
'onPrepareOptionsMenu'
237237
];
238+
239+
exports.COMMANDS = {
240+
GENERATE: 'generate'
241+
};

Alloy/utils.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ exports.evaluateTemplate = function(name, o) {
110110
return _.template(exports.readTemplate(name), o);
111111
};
112112

113-
exports.getAndValidateProjectPaths = function(argPath) {
114-
var projectPath = path.resolve(argPath);
113+
exports.getAndValidateProjectPaths = function(argPath, opts) {
114+
var projectPath = path.resolve(argPath),
115+
opts = opts || {};
115116

116117
// See if we got the "app" path or the project path as an argument
117118
projectPath = fs.existsSync(path.join(projectPath,'..','tiapp.xml')) ?
@@ -135,7 +136,7 @@ exports.getAndValidateProjectPaths = function(argPath) {
135136
exports.die('Invalid Titanium project path (no tiapp.xml) at "' + paths.project + '"');
136137
} else if (!fs.existsSync(paths.app)) {
137138
exports.die('Alloy "app" directory does not exist at "' + paths.app + '"');
138-
} else if (!fs.existsSync(paths.index)) {
139+
} else if (!fs.existsSync(paths.index) && (opts.command !== CONST.COMMANDS.GENERATE)) {
139140
exports.die('Alloy "app" directory has no "' + paths.indexBase + '" file at "' + paths.index + '".');
140141
}
141142

0 commit comments

Comments
 (0)