Skip to content

Commit 6e5bb52

Browse files
committed
fix: use platform-agnostic paths, and add test to be sure
1 parent 9989c0a commit 6e5bb52

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858
"chalk": "^4.1.2",
5959
"fs-extra": "^10.0.0",
6060
"moize": "^6.1.0",
61-
"node-stream-zip": "^1.15.0",
6261
"node-fetch": "^2.6.5",
62+
"node-stream-zip": "^1.15.0",
6363
"outdent": "^0.8.0",
6464
"p-limit": "^3.1.0",
6565
"pathe": "^0.2.0",

src/helpers/functions.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
const { join, relative } = require('path')
2-
31
const { copyFile, ensureDir, writeFile, writeJSON } = require('fs-extra')
2+
const { join, relative } = require('pathe')
43

54
const { HANDLER_FUNCTION_NAME, ODB_FUNCTION_NAME, IMAGE_FUNCTION_NAME } = require('../constants')
65
const getHandler = require('../templates/getHandler')

test/index.js

+24
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,30 @@ describe('onBuild()', () => {
223223
expect(readFileSync(handlerPagesFile, 'utf8')).toMatchSnapshot()
224224
expect(readFileSync(odbHandlerPagesFile, 'utf8')).toMatchSnapshot()
225225
})
226+
227+
test('generates entrypoints with correct references', async () => {
228+
const handlerFile = path.join(
229+
SAMPLE_PROJECT_DIR,
230+
'.netlify',
231+
'functions-internal',
232+
HANDLER_FUNCTION_NAME,
233+
`${HANDLER_FUNCTION_NAME}.js`,
234+
)
235+
const odbHandlerFile = path.join(
236+
SAMPLE_PROJECT_DIR,
237+
'.netlify',
238+
'functions-internal',
239+
ODB_FUNCTION_NAME,
240+
`${ODB_FUNCTION_NAME}.js`,
241+
)
242+
expect(existsSync(handlerFile)).toBeTruthy()
243+
expect(existsSync(odbHandlerFile)).toBeTruthy()
244+
245+
expect(readFileSync(handlerFile, 'utf8')).toMatch(`(config, "../../..", pageRoot, staticManifest)`)
246+
expect(readFileSync(odbHandlerFile, 'utf8')).toMatch(`(config, "../../..", pageRoot, staticManifest)`)
247+
expect(readFileSync(handlerFile, 'utf8')).toMatch(`require("../../../.next/required-server-files.json")`)
248+
expect(readFileSync(odbHandlerFile, 'utf8')).toMatch(`require("../../../.next/required-server-files.json")`)
249+
})
226250
})
227251

228252
describe('onPostBuild', () => {

0 commit comments

Comments
 (0)