diff --git a/lib/shared/permissions.js b/lib/shared/permissions.js index a47d4859..80d99987 100644 --- a/lib/shared/permissions.js +++ b/lib/shared/permissions.js @@ -99,7 +99,12 @@ exports.getEnvironmentCommandPrefix = (environment) => { } if (isWindows) { - return [ 'set', `${key}=${value}`, '&&' ] + // Doing something like `set foo=bar &&` (notice + // the space before the first ampersand) would + // cause the environment variable's value to + // contain a trailing space. + // See https://superuser.com/a/57726 + return [ 'set', `${key}=${value}&&` ] } return [ `${key}=${value}` ] diff --git a/tests/shared/permissions.spec.js b/tests/shared/permissions.spec.js index 436fb455..31cf64ff 100644 --- a/tests/shared/permissions.spec.js +++ b/tests/shared/permissions.spec.js @@ -45,8 +45,7 @@ describe('Shared: permissions', function () { FOO: 'bar' })).to.deep.equal([ 'set', - 'FOO=bar', - '&&', + 'FOO=bar&&', 'call' ]) }) @@ -58,14 +57,11 @@ describe('Shared: permissions', function () { BAZ: 'qux' })).to.deep.equal([ 'set', - 'FOO=bar', - '&&', + 'FOO=bar&&', 'set', - 'BAR=baz', - '&&', + 'BAR=baz&&', 'set', - 'BAZ=qux', - '&&', + 'BAZ=qux&&', 'call' ]) }) @@ -77,8 +73,7 @@ describe('Shared: permissions', function () { BAZ: undefined })).to.deep.equal([ 'set', - 'BAR=qux', - '&&', + 'BAR=qux&&', 'call' ]) }) @@ -90,14 +85,11 @@ describe('Shared: permissions', function () { BAZ: -1 })).to.deep.equal([ 'set', - 'FOO=1', - '&&', + 'FOO=1&&', 'set', - 'BAR=0', - '&&', + 'BAR=0&&', 'set', - 'BAZ=-1', - '&&', + 'BAZ=-1&&', 'call' ]) })