Browse files

CB-5947 Throw when trying to create project inside custom www.

If a custom www dir is provided and is a parent or the same as the project dir,
cordova create fails while trying to create an infinite file hierarchy. Detect
this and exit with an error.
  • Loading branch information...
1 parent 6d05d94 commit d55087fd6c41da0db6a6ec097b24077d5f092dd2 @kamrik kamrik committed with agrieve Jan 30, 2014
Showing with 7 additions and 0 deletions.
  1. +7 −0 src/create.js
View
7 src/create.js
@@ -90,6 +90,13 @@ module.exports = function create (dir, id, name, cfg) {
var www_version = config_json.lib.www.version || 'not_versioned';
var www_id = config_json.lib.www.id || 'dummy_id';
symlink = !!config_json.lib.www.link;
+ if ( www_dir.indexOf(path.resolve(config_json.lib.www.uri)) === 0 ) {
+ throw new CordovaError(
+ 'Project must not be created inside the www assets dir.' +
+ '\n project dir:\t' + dir +
+ '\n www assets dir:\t' + config_json.lib.www.uri
+ );
+ }
if(symlink) {
p = Q(config_json.lib.www.uri);
events.emit('verbose', 'Symlinking custom www assets into "' + www_dir + '"');

0 comments on commit d55087f

Please sign in to comment.