Skip to content

Commit

Permalink
fix: Resolving issue passing TMI.
Browse files Browse the repository at this point in the history
closes #41
  • Loading branch information
mrsteele committed Mar 7, 2017
1 parent f989f68 commit 893d0d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
13 changes: 8 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Dotenv {
let vars = {}
if (options.systemvars) {
Object.keys(process.env).map(key => {
vars[key] = JSON.stringify(process.env[key])
vars[key] = process.env[key]
})
}

Expand All @@ -50,13 +50,16 @@ class Dotenv {
if (!value && options.safe) {
throw new Error(`Missing environment variable: ${key}`)
} else {
vars[key] = JSON.stringify(value)
vars[key] = value
}
})

return new DefinePlugin({
'process.env': vars
})
const formatData = Object.keys(vars).reduce((obj, key) => {
obj[`process.env.${key}`] = JSON.stringify(vars[key])
return obj
}, {})

return new DefinePlugin(formatData)
}

/**
Expand Down
6 changes: 3 additions & 3 deletions test/main.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ const envMissingOne = path.resolve(__dirname, './envs/.missingone')
const envMissingOneExample = path.resolve(__dirname, './envs/.missingone.example')

const envEmptyJson = {}
const envSimpleJson = {TEST: '"testing"'}
const envMissingOneJson = {TEST: '""', TEST2: '"Hello"'}
const envSimpleJson = {'process.env.TEST': '"testing"'}
const envMissingOneJson = {'process.env.TEST': '""', 'process.env.TEST2': '"Hello"'}

function runTests (Obj, name) {
function envTest (config) {
return new Obj(config).definitions['process.env']
return new Obj(config).definitions
}

/** @test {Dotenv} **/
Expand Down

0 comments on commit 893d0d0

Please sign in to comment.