Skip to content

Commit

Permalink
fix exporting issue. properly set FRIDGE_SECRET to empty string if it is
Browse files Browse the repository at this point in the history
not present in config
  • Loading branch information
tamagokun committed Jan 8, 2018
1 parent 5847db7 commit 3391271
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
5 changes: 4 additions & 1 deletion bin/fridge
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
import { join } from 'path'
import { spawn } from 'cross-spawn'

const cmd = process.argv[2] || process.env.NODE_ENV === 'production' ? 'start' : 'dev'
const cmd = process.argv[2] || (process.env.NODE_ENV === 'production' ? 'start' : 'dev')
const bin = join(__dirname, 'fridge-' + cmd + '.js')

const defaultEnv = cmd === 'dev' ? 'development' : 'production'
process.env.NODE_ENV = process.env.NODE_ENV || defaultEnv

const startProcess = () => {
const proc = spawn(bin, [], {stdio: 'inherit', customFds: [0, 1, 2]})
proc.on('close', (code, signal) => {
Expand Down
2 changes: 0 additions & 2 deletions bin/fridge-dev
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env node

process.env.NODE_ENV = process.env.NODE_ENV || 'development'

import fridge from '../'
fridge().start(process.env.PORT || 3000)
2 changes: 0 additions & 2 deletions bin/fridge-start
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env node

process.env.NODE_ENV = 'production'

import fridge from '../'
fridge().start(process.env.PORT || 3000)
15 changes: 11 additions & 4 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ const Fridge = require('fridge')

const cache = new Map()

const defaultConfig = {
poweredByHeader: true,
distDir: '.next',
assetPrefix: '',
useFileSystemPublicRoutes: false
}

module.exports = (dir) => {
if (!cache.has(dir)) {
cache.set(dir, loadConfig(dir))
Expand All @@ -30,18 +37,18 @@ const loadConfig = (dir) => {
const {client_id, public_id, client_secret} = userConfig.fridge

process.env.FRIDGE_ID = client_id || public_id // eslint-disable-line
process.env.FRIDGE_SECRET = client_secret // eslint-disable-line
process.env.FRIDGE_SECRET = client_secret || '' // eslint-disable-line

if (typeof userConfig.exportPathMap === 'function') {
const fridge = new Fridge({
client_id: process.env.FRIDGE_ID,
client_secret: process.env.FRIDGE_SECRET
})
userConfig.exportPathMap = () => userConfig.exportPathMap(fridge)
const exportFn = userConfig.exportPathMap
userConfig.exportPathMap = () => exportFn(fridge)
}

return Object.assign({}, userConfig, {
useFileSystemPublicRoutes: false,
return Object.assign({}, defaultConfig, userConfig, {
webpack: (config, ...args) => {
if (userConfig.webpack) {
config = userConfig.webpack(config, ...args)
Expand Down

0 comments on commit 3391271

Please sign in to comment.