Skip to content

Commit e16d17b

Browse files
committed
fix: tests
1 parent e9287b9 commit e16d17b

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

Diff for: helpers/defaultFailBuild.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
exports.defaultFailBuild = function (message, { error }) {
2+
throw new Error(`${message}\n${error.stack}`)
3+
}

Diff for: helpers/getNextConfig.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
const { resolve } = require('path')
44

5+
const { defaultFailBuild } = require('./defaultFailBuild')
56
const moize = require('moize')
67

78
// Load next.config.js
8-
const getNextConfig = async function (publishPath, failBuild = defaultFailBuild) {
9+
const getNextConfig = async function (failBuild = defaultFailBuild, publishPath = '.') {
910
// We cannot load `next` at the top-level because we validate whether the
1011
// site is using `next` inside `onPreBuild`.
1112
const { PHASE_PRODUCTION_BUILD } = require('next/constants')
@@ -20,8 +21,4 @@ const getNextConfig = async function (publishPath, failBuild = defaultFailBuild)
2021

2122
const moizedGetNextConfig = moize(getNextConfig, { maxSize: 1e3, isPromise: true })
2223

23-
const defaultFailBuild = function (message, { error }) {
24-
throw new Error(`${message}\n${error.stack}`)
25-
}
26-
2724
module.exports = moizedGetNextConfig

Diff for: src/lib/helpers/getNextDistDir.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// Get the NextJS distDir specified in next.config.js
22
const { join } = require('path')
3+
34
const getNextConfig = require('../../../helpers/getNextConfig')
5+
const { defaultFailBuild } = require('../../../helpers/defaultFailBuild')
46

57
const getNextDistDir = async (publishPath) => {
6-
const nextConfig = await getNextConfig(publishPath)
8+
const nextConfig = await getNextConfig(defaultFailBuild, publishPath)
79

810
return join('.', nextConfig.distDir)
911
}

0 commit comments

Comments
 (0)