Skip to content

Commit

Permalink
Refactor Next.js patches into their own file
Browse files Browse the repository at this point in the history
This refactors the Next.js logger patches into their own file, to be imported in the `index` file. This a precursor to presets.
  • Loading branch information
atkinchris committed Apr 30, 2021
1 parent fdd94d8 commit 0e1fabd
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
*
!index.js
!lib/*
!lib/**/*
13 changes: 1 addition & 12 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1 @@
const LOGGER_PATH = require('path').join(process.cwd(), 'node_modules', 'next/dist/build/output/log')

// eslint-disable-next-line import/no-dynamic-require
const nextLogger = require(LOGGER_PATH)

const buildJsonLogger = require('./lib/jsonLogger')

Object.entries(nextLogger).forEach(([key, value]) => {
if (typeof value === 'function') {
nextLogger[key] = buildJsonLogger(key)
}
})
require('./lib/patches/next')
12 changes: 12 additions & 0 deletions lib/patches/next.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const LOGGER_PATH = require('path').join(process.cwd(), 'node_modules', 'next/dist/build/output/log')

// eslint-disable-next-line import/no-dynamic-require
const nextLogger = require(LOGGER_PATH)

const buildJsonLogger = require('../jsonLogger')

Object.entries(nextLogger).forEach(([key, value]) => {
if (typeof value === 'function') {
nextLogger[key] = buildJsonLogger(key)
}
})
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next-logger",
"version": "1.1.1",
"version": "1.2.0",
"description": "JSON logging patcher for Next.js",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 0e1fabd

Please sign in to comment.