Skip to content

Commit f44e242

Browse files
committed
chore: fix tests
1 parent f3e671d commit f44e242

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

helpers/getNextRoot.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const path = require('path')
33

44
const getNextRoot = ({ netlifyConfig }) => {
55
let nextRoot = process.cwd()
6-
if (!existsSync(path.join(nextRoot, 'next.config.js'))) {
6+
if (!existsSync(path.join(nextRoot, 'next.config.js')) && netlifyConfig.build.publish) {
77
nextRoot = path.dirname(netlifyConfig.build.publish)
88
}
99
return nextRoot

index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,17 @@ module.exports = {
8080
})
8181
},
8282

83-
async onPostBuild({ netlifyConfig, packageJson, constants: { FUNCTIONS_DIST }, utils }) {
83+
async onPostBuild({ netlifyConfig, packageJson, constants: { FUNCTIONS_DIST = DEFAULT_FUNCTIONS_DIST }, utils }) {
8484
if (doesNotNeedPlugin({ netlifyConfig, packageJson, utils })) {
8585
return
8686
}
8787
const nextRoot = getNextRoot({ netlifyConfig })
8888

8989
const nextConfig = await getNextConfig(utils.failBuild, nextRoot)
90-
await saveCache({ cache: utils.cache, distDir: path.join(nextRoot, nextConfig.distDir) })
90+
await saveCache({ cache: utils.cache, distDir: nextConfig.distDir })
9191
copyUnstableIncludedDirs({ nextConfig, functionsDist: path.resolve(FUNCTIONS_DIST) })
9292
},
9393
}
9494

9595
const DEFAULT_FUNCTIONS_SRC = 'netlify/functions'
96+
const DEFAULT_FUNCTIONS_DIST = '.netlify/functions/'

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const watch = (functionsPath, publishPath, nextRoot) => {
7575
const nextOnNetlify = async (options = {}) => {
7676
const functionsPath = normalize(options.functionsDir || NETLIFY_FUNCTIONS_PATH)
7777
const publishPath = normalize(options.publishDir || NETLIFY_PUBLISH_PATH)
78-
const nextRoot = normalize(options.nextRoot) || process.cwd()
78+
const nextRoot = normalize(options.nextRoot || process.cwd())
7979

8080
if (options.watch) {
8181
watch(functionsPath, publishPath, nextRoot)

test/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const { readdirSync } = require('fs')
12
const path = require('path')
23
const process = require('process')
34

@@ -202,7 +203,7 @@ describe('onBuild()', () => {
202203
await moveNextDist()
203204
const PUBLISH_DIR = 'publish'
204205
await plugin.onBuild({
205-
netlifyConfig,
206+
netlifyConfig: { build: { publish: path.resolve(PUBLISH_DIR) } },
206207
packageJson: DUMMY_PACKAGE_JSON,
207208
constants: {
208209
PUBLISH_DIR,

0 commit comments

Comments
 (0)