Skip to content

Commit

Permalink
fix: always watch internal functions dir
Browse files Browse the repository at this point in the history
this has the side-effect that we're *always* starting the function server!
  • Loading branch information
Skn0tt committed Dec 7, 2023
1 parent 7b47d92 commit 8127e3e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
4 changes: 1 addition & 3 deletions src/utils/functions/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,5 @@ export const getInternalFunctionsDir = async ({ base, ensureExists, packagePath
await fs.mkdir(path, { recursive: true })
}

const isDirectory = await isDirectoryAsync(path)

return isDirectory ? path : null
return path
}
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ exports.handler = async () => ({
})
})

test.skip('Serves functions from the internal functions directory', async (t) => {
test('Serves functions from the internal functions directory', async (t) => {
await withSiteBuilder('function-internal', async (builder) => {
const bundlerConfig = args.includes('esbuild') ? { node_bundler: 'esbuild' } : {}

Expand All @@ -506,17 +506,22 @@ exports.handler = async () => ({
...bundlerConfig,
},
})
.withFunction({
path: 'hello.js',
pathPrefix: '.netlify/functions-internal',
handler: async () => ({
statusCode: 200,
body: 'Internal',
}),
})
.buildAsync()
.build()

await withDevServer({ cwd: builder.directory, args }, async ({ outputBuffer, port, waitForLogMatching }) => {
await builder
.withFunction({
path: 'hello.js',
pathPrefix: '.netlify/functions-internal',
handler: async () => ({
statusCode: 200,
body: 'Internal',
}),
})
.build()

await pause(WAIT_WRITE)

await tryAndLogOutput(async () => {
t.expect(await fetch(`http://localhost:${port}/.netlify/functions/hello`).then((res) => res.text())).toEqual(
'Internal',
Expand Down

0 comments on commit 8127e3e

Please sign in to comment.