Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-14789] Fixed bug with help prompting for platform instead of disp... #52

Merged
merged 1 commit into from
Aug 8, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 7 additions & 5 deletions lib/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,12 @@ Context.prototype.load = function load(logger, config, cli, callback) {
}

// parse the args to get the --platform
var argv = this.parse(cli.argv.$_, Object.keys(this.commands));
var argv = this.parse(cli.argv.$_, Object.keys(this.commands)),
isHelpCommand = cli.argv.$command == 'help';

// since the parse call above squashes the args array, we check the original if
// it's the help command (via --help)... generally they are the same anyways
if (cli.argv.$command == 'help') {
if (isHelpCommand) {
argv._ = cli.argv._;
}

Expand Down Expand Up @@ -410,11 +412,11 @@ Context.prototype.load = function load(logger, config, cli, callback) {
}
}.bind(this);

if (argv.platform) {
if (!isHelpCommand && argv.platform) {
// --platform was set, the load only that platform
loadPlatform();

} else if (options.platform.required) {
} else if (!isHelpCommand && options.platform.required) {
// no --platform, but it's required, so prompt for it
logger.banner();

Expand Down Expand Up @@ -474,7 +476,7 @@ Context.prototype.load = function load(logger, config, cli, callback) {
});
return;

} else if (conf.platforms && cli.sdk && cli.sdk.path) {
} else if (isHelpCommand || (conf.platforms && cli.sdk && cli.sdk.path)) {
// no platform specified, load all platforms and set their options and flags
Object.keys(conf.platforms).forEach(function (platform) {
this.platforms[platform] = new Context({
Expand Down
19 changes: 16 additions & 3 deletions lib/titanium.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,35 @@
var fs = require('fs'),
path = require('path'),
colors = require('colors'),
semver = require('semver');
semver = require('semver'),
pkgJson = require('../package.json');

// set path.existsSync to make old modules designed for <=0.6 happy
path.existsSync = fs.existsSync || path.existsSync;

// check that we're using Node.js 0.8 or newer
try {
if (semver.lt(process.version, '0.8.0')) {
var info = require('../package.json');
console.error(info.about.name.cyan.bold + ', CLI version ' + info.version + '\n' + info.about.copyright + '\n\n' +
console.error(pkgJson.about.name.cyan.bold + ', CLI version ' + pkgJson.version + '\n' + pkgJson.about.copyright + '\n\n' +
'ERROR: Titanium requires Node.js 0.8 or newer.'.red + '\n\n' +
'Visit ' + 'http://nodejs.org/'.cyan + ' to download a newer version.\n');
process.exit(1);
}
} catch (e) {}

// check that node-appc is up-to-date
try {
var nodeAppcPkgJson = require('node-appc/package.json');
if (!semver.satisfies(nodeAppcPkgJson.version, pkgJson.dependencies['node-appc'])) {
console.error(pkgJson.about.name.cyan.bold + ', CLI version ' + pkgJson.version + '\n' + pkgJson.about.copyright + '\n\n' +
('ERROR: node-appc version ' + nodeAppcPkgJson.version + ' too old; version ' + pkgJson.dependencies['node-appc'] + ' required').red + '\n\n' +
'Run ' + ('cd ' + path.dirname(__dirname) + ' && npm update').cyan + ' to update to the latest version.\n');
process.exit(1);
}
} catch (e) {
console.log(e);
}

require('longjohn');

// read the locale and bootstrap the CLI as necessary
Expand Down