Skip to content

Commit

Permalink
more robust parsing for iron run iron-meteor#140 iron-meteor#175
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbutler committed Aug 16, 2015
1 parent 53a313d commit 4b014a8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
31 changes: 24 additions & 7 deletions lib/commands/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var fs = require('fs');
var spawn = require('child_process').spawn;
var source = require('shell-source');
var Future = require('fibers/future');
var _ = require('underscore');

var syncSource = function (filepath) {
var future = new Future;
Expand All @@ -15,17 +16,27 @@ Command.create({
usage: 'iron run [--use-build] [--env]',
description: 'Run your app for a given environment.'
}, function (args, opts) {
var appEnv = opts.env || process.env.NODE_ENV || 'development';

if (!this.findProjectDirectory())
throw new Command.MustBeInProjectError;

var configPath = this.pathFromProject('config', appEnv);
var envPath = path.join(configPath, 'env.sh');
var settingsPath = path.join(configPath, 'settings.json');
var appEnv = process.env.NODE_ENV || 'development',
configPath = this.pathFromProject('config', appEnv),
envPath = path.join(configPath, 'env.sh'),
settingsPath;

// source the env file into the process environment
if (opts.env) {
appEnv = opts.env;
configPath = this.pathFromProject('config', appEnv);
}

// allow settings override
if (opts.settings) {
settingsPath = opts.settings;
} else {
settingsPath = path.join(configPath, 'settings.json');
}

// source the env file into the process environment
if (this.isFile(envPath)) {
syncSource(envPath);
}
Expand All @@ -37,5 +48,11 @@ Command.create({
]);
}

return this.invokeMeteorCommand('run', args.concat(process.argv.slice(3)));
// remove run and any platforms
var r = args.concat(_.without(process.argv.slice(2), 'run', args[0]));

// don't pass --env to meteor
r = _.without(r, appEnv, '--env');

return this.invokeMeteorCommand('run', r);
});
7 changes: 6 additions & 1 deletion lib/iron.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ Iron = new Command({
console.log(table.toString());
}
}, function (args, opts) {
var command = args[0] || 'run';
var command = 'run';
if (args[0]) {
command = args[0];
} else {
args[0] = command;
}

if (this.findSubCommand(command)) {
return this.runSubCommand(command, args.slice(1), opts);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"dependencies": {
"cli-color": "0.2.3",
"minimist": "0.0.8",
"underscore": "1.3.3",
"underscore": "1.8.3",
"cli-table": "0.3.0",
"ejs": "0.8.5",
"fibers": "1.0.6",
Expand Down

0 comments on commit 4b014a8

Please sign in to comment.