Auto-merge for PR #665 via VersionBot

Ignore leading and trailing whitespace when parsing env vars
This commit is contained in:
resin-io-versionbot[bot] 2018-05-22 11:07:52 +00:00 committed by GitHub
commit 8018b960aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 2 deletions

View File

@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file
automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY! automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
This project adheres to [Semantic Versioning](http://semver.org/). This project adheres to [Semantic Versioning](http://semver.org/).
## v7.7.2 - 2018-05-22
* Ignore leading and trailing whitespace when parsing env vars #665 [Cameron Diver]
## v7.7.1 - 2018-05-21 ## v7.7.1 - 2018-05-21
* Don't generate config fields in offline mode #651 [Cameron Diver] * Don't generate config fields in offline mode #651 [Cameron Diver]

View File

@ -1,7 +1,7 @@
{ {
"name": "resin-supervisor", "name": "resin-supervisor",
"description": "This is resin.io's Supervisor, a program that runs on IoT devices and has the task of running user Apps (which are Docker containers), and updating them as Resin's API informs it to.", "description": "This is resin.io's Supervisor, a program that runs on IoT devices and has the task of running user Apps (which are Docker containers), and updating them as Resin's API informs it to.",
"version": "7.7.1", "version": "7.7.2",
"license": "Apache-2.0", "license": "Apache-2.0",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -4,7 +4,7 @@ import { EnvVarObject } from './types';
export function envArrayToObject(env: string[]): EnvVarObject { export function envArrayToObject(env: string[]): EnvVarObject {
const toPair = (keyVal: string) => { const toPair = (keyVal: string) => {
const m = keyVal.match(/^([^=]+)=(.*)$/); const m = keyVal.match(/^([^=]+)=\s*(.*)\s*$/);
if (m == null) { if (m == null) {
console.log(`WARNING: Could not correctly parse env var ${keyVal}. ` + console.log(`WARNING: Could not correctly parse env var ${keyVal}. ` +
'Please fix this var and recreate the container.'); 'Please fix this var and recreate the container.');

View File

@ -36,3 +36,14 @@ describe 'conversions', ->
expect(conversion.envArrayToObject('')).to.deep.equal({}) expect(conversion.envArrayToObject('')).to.deep.equal({})
expect(conversion.envArrayToObject([])).to.deep.equal({}) expect(conversion.envArrayToObject([])).to.deep.equal({})
expect(conversion.envArrayToObject(1)).to.deep.equal({}) expect(conversion.envArrayToObject(1)).to.deep.equal({})
it 'should ignore leading and trailing whitespace', ->
expect(conversion.envArrayToObject([
'TEST=\ntest'
'TEST2=test\n'
'TEST3=\ntest\n'
])).to.deep.equal({
TEST: 'test'
TEST2: 'test'
TEST3: 'test'
})