diff --git a/cli/run/index.ts b/cli/run/index.ts index 53825ce2c1e..5bf7d73dd6e 100644 --- a/cli/run/index.ts +++ b/cli/run/index.ts @@ -9,7 +9,7 @@ import build from './build'; import loadConfigFile from './loadConfigFile'; import watch from './watch'; -export default function runRollup(command: any) { +export default function runRollup (command: any) { let inputSource; if (command._.length > 0) { if (command.input) { @@ -47,9 +47,9 @@ export default function runRollup(command: any) { environment.forEach((arg: string) => { arg.split(',').forEach((pair: string) => { - const [key, value] = pair.split(':'); - if (value) { - process.env[key] = value; + const [key, ...value] = pair.split(':'); + if (value.length) { + process.env[key] = value.join(':'); } else { process.env[key] = String(true); } @@ -93,7 +93,7 @@ export default function runRollup(command: any) { } } -function execute(configFile: string, configs: GenericConfigObject[], command: any) { +function execute (configFile: string, configs: GenericConfigObject[], command: any) { if (command.watch) { watch(configFile, configs, command, command.silent); } else { diff --git a/test/cli/samples/config-env/_config.js b/test/cli/samples/config-env/_config.js index 5b5f4936b00..3036cc208f5 100644 --- a/test/cli/samples/config-env/_config.js +++ b/test/cli/samples/config-env/_config.js @@ -1,5 +1,5 @@ module.exports = { description: 'passes environment variables to config file', - command: 'rollup --config --environment PRODUCTION,FOO:bar', + command: 'rollup --config --environment PRODUCTION,FOO:bar,HOST:http://localhost:4000', execute: true }; diff --git a/test/cli/samples/config-env/main.js b/test/cli/samples/config-env/main.js index b18f7a91323..595e774fb84 100644 --- a/test/cli/samples/config-env/main.js +++ b/test/cli/samples/config-env/main.js @@ -1,2 +1,3 @@ assert.equal( '__ENVIRONMENT__', 'production' ); assert.equal( '__FOO__', 'bar' ); +assert.equal( '__HOST__', 'http://localhost:4000' ); diff --git a/test/cli/samples/config-env/rollup.config.js b/test/cli/samples/config-env/rollup.config.js index cd113e77749..7fe713ad17b 100644 --- a/test/cli/samples/config-env/rollup.config.js +++ b/test/cli/samples/config-env/rollup.config.js @@ -8,7 +8,8 @@ module.exports = { plugins: [ replace( { __ENVIRONMENT__: process.env.PRODUCTION ? 'production' : 'development', - __FOO__: process.env.FOO + __FOO__: process.env.FOO, + __HOST__: process.env.HOST } ) ] };