Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
Add ability to pass through an --env flag to huron webpack build
Browse files Browse the repository at this point in the history
  • Loading branch information
ostowe committed Mar 15, 2017
1 parent 5cdf593 commit e7fdb06
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
19 changes: 18 additions & 1 deletion dist/cli/huron-cli.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/cli/huron-cli.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/cli/generate-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function generateConfig() {

// Execute config function, if provided
if ('function' === typeof newConfig) {
newConfig = newConfig({});
newConfig = newConfig(program.env);
}

// Set ouput options
Expand Down
19 changes: 19 additions & 0 deletions src/cli/parse-args.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @module cli/parse-arguments */
/* eslint-disable space-unary-ops */

// Requires
/** @global */
Expand All @@ -14,6 +15,21 @@ export default program;
* @example node huron/dist/cli/huron-cli.js --config 'client/config/webpack.config.js' --production
*/
function parseArgs() {
const envArg = {};

process.argv = process.argv.filter((arg) => {
if (-1 !== arg.indexOf('--env')) {
const envParts = arg
.split('.')[1]
.split('=');

envArg[envParts[0]] = envParts[1] || true;
return false;
}

return true;
});

program.version('1.0.1')
.option(
'-c, --huron-config [huronConfig]',
Expand All @@ -27,6 +43,9 @@ function parseArgs() {
)
.option('-p, --production', 'compile assets once for production')
.parse(process.argv);

program.env = envArg;
}

parseArgs();
/* eslint-enable */

0 comments on commit e7fdb06

Please sign in to comment.