fix for the handling of bad input in "mojito jsling mojit" command #542

Merged
merged 2 commits into from Dec 10, 2012
@@ -12,7 +12,15 @@ var fs = require('fs'),
path = require('path'),
existsSync = fs.existsSync || path.existsSync,
utils = require(path.join(__dirname, '../../management/utils')),
- usage = 'mojito jslint [app | mojit] [<name>] {options}\n' +
+ usage = 'mojito jslint [app | mojit] [<path>] {options}\n' +
+ '\t- target: app or mojit\n' +
+ '\t- path (required for a mojit target): the path to the mojit to run jslint on\n\n' +
+ 'Run jslint on the app in the current directory:\n' +
+ '\tmojito jslint app .\n' +
+ 'Run jslint on mojits/Bar:\n' +
+ '\tmojito jslint mojit ./mojits/Bar\n' +
+ 'Run jslint on the mojito framework itself!\n' +
+ '\tmojito jslint\n' +
'\nOPTIONS: \n' +
'\t --print : print results to stdout \n' +
'\t -p : short for --print\n',
@@ -409,6 +417,7 @@ function run(params, options) {
outDir,
failures,
errors,
+ mojit_path,
print = options && options.print;
// Process params to determine input and output locations.
@@ -442,13 +451,22 @@ function run(params, options) {
];
} else if (params[0] === 'mojit') {
// mojit
- inDir = getMojitDir(params[1]);
+ mojit_path = params[1];
+ if (!mojit_path) {
+ utils.error('Please specify the path to mojit', exports.usage);
+ return;
+ }
+ inDir = getMojitDir(mojit_path);
+ if (!existsSync(inDir)) {
+ utils.error('Mojit ' + mojit_path + ' not found.', usage);
+ return;
+ }
if (!inDir) {
- utils.error('Mojit not found.', usage);
+ utils.error('Mojit ' + mojit_path + ' not found.', usage);
return;
}
outDir = path.join(inDir, 'artifacts/jslint/mojits',
- getMojitName(params[1]));
+ getMojitName(mojit_path));
excludes = [
/\/tests$/,
/\/artifacts$/,