Skip to content

Commit

Permalink
Don't mutate global config object
Browse files Browse the repository at this point in the history
Closes #152
  • Loading branch information
RyanZim committed Feb 6, 2018
1 parent e0c7d9e commit 4e29626
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const output = argv.output

if (argv.map) argv.map = { inline: false }

let config = {
const cliConfig = {
options: {
map: argv.map !== undefined ? argv.map : { inline: true },
parser: argv.parser ? require(argv.parser) : undefined,
Expand Down Expand Up @@ -117,7 +117,7 @@ Promise.resolve()
})

function rc(ctx, path) {
if (argv.use) return Promise.resolve()
if (argv.use) return Promise.resolve(cliConfig)

// Set argv: false to keep cosmiconfig from attempting to read the --config
// flag from process.argv
Expand All @@ -128,7 +128,7 @@ function rc(ctx, path) {
'Config Error: Can not set from or to options in config file, use CLI arguments instead'
)
}
config = rc
return rc
})
.catch(err => {
if (err.message.indexOf('No PostCSS Config found') === -1) throw err
Expand Down Expand Up @@ -175,7 +175,7 @@ function css(css, file) {
printVerbose(chalk`{cyan Processing {bold ${relativePath}}...}`)

return rc(ctx, argv.config)
.then(() => {
.then(config => {
const options = config.options

if (file === 'stdin' && output) file = output
Expand Down

0 comments on commit 4e29626

Please sign in to comment.