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

Allow environment variables to contain colons #3283

Merged
merged 3 commits into from Dec 14, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 3 additions & 3 deletions cli/run/index.ts
Expand Up @@ -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 && value.length) {
tlaverdure marked this conversation as resolved.
Show resolved Hide resolved
process.env[key] = value.join(':');
} else {
process.env[key] = String(true);
}
Expand Down
2 changes: 1 addition & 1 deletion 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
};
1 change: 1 addition & 0 deletions 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' );
3 changes: 2 additions & 1 deletion test/cli/samples/config-env/rollup.config.js
Expand Up @@ -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
} )
]
};