From b0617f1ad4bcff610056baff977122cd77907668 Mon Sep 17 00:00:00 2001 From: Praveen Innamuri Date: Sat, 16 May 2015 19:40:29 -0700 Subject: [PATCH] [CLI-629] Fix invalid 'titanium' path for Windows --- node_modules/titanium-sdk/lib/titanium.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/node_modules/titanium-sdk/lib/titanium.js b/node_modules/titanium-sdk/lib/titanium.js index 6e3a14c2dc0..96c02ba67dd 100644 --- a/node_modules/titanium-sdk/lib/titanium.js +++ b/node_modules/titanium-sdk/lib/titanium.js @@ -550,7 +550,22 @@ exports.validateCorrectSDK = function (logger, config, cli, commandName) { hideBanner = true; - cmdAdd(argv.$0.split(' ').pop()); + // If the titanium path has spaces, then we are trying to combine the paths and verify after they were split. + var titaniumPath = function getTitaniumPath (params) { + var paramsArray = params.split(' '), + pathSegment, + prevPath = ''; + while ((pathSegment = paramsArray.pop())) { + if (fs.existsSync(pathSegment + prevPath)) { + return pathSegment + prevPath; + } + prevPath = ' ' + pathSegment; + } + // fallback to default last segment, if we fail for any reason. + return params.split(' ').pop(); + }(argv.$0); + + cmdAdd(titaniumPath); cmdAdd(commandName, '--sdk', sdkName); var flags = {},