Skip to content

Commit

Permalink
fix: logger (#395)
Browse files Browse the repository at this point in the history
  • Loading branch information
reyronald committed Dec 5, 2020
1 parent facb6c1 commit 46caafa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
"precommit": "lint-staged",
"prettier": "prettier --write \"./**/*.{js,jsx,json,css,md,html}\"",
"xo": "xo *.js {src,test,scripts}/**/*.js !src/vendor/*.*",
"ava": "cross-env BABEL_ENV=testing ava",
"ava": "cross-env NODE_ENV=test BABEL_ENV=testing ava",
"ava:w": "npm run ava -- --watch",
"flow": "flow check --color=always",
"flow:w": "flow check --color=always & chokidar \"src/**/*.js\" -c \"flow check\"",
"build": "webpack",
"build": "cross-env NODE_ENV=production webpack",
"test": "npm-run-all xo ava flow build",
"watch": "webpack --watch",
"watch": "cross-env NODE_ENV=development webpack --watch",
"sync-version": "node scripts/sync-version",
"package": "node scripts/package",
"deploy": "npm-run-all test sync-version package && node scripts/deploy",
Expand Down
4 changes: 3 additions & 1 deletion src/logger.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// @flow

const isTestingEnvironment = process.env.NODE_ENV === 'test'

const logger: typeof console = Object.keys(console).reduce(
(previous, current) => {
previous[current] = (...args: any[]) => {
if (!process) {
if (!isTestingEnvironment) {
console[current](...args)
}
}
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
},
plugins: [
new webpack.DefinePlugin({
process: {},
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
}),
new webpack.optimize.ModuleConcatenationPlugin(),
new CopyWebpackPlugin([
Expand Down

0 comments on commit 46caafa

Please sign in to comment.