From 8127e3e1238db4855053b093a8797ff0d4894add Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Thu, 7 Dec 2023 17:48:12 +0100 Subject: [PATCH] fix: always watch internal functions dir this has the side-effect that we're *always* starting the function server! --- src/utils/functions/functions.ts | 4 +-- .../functions-with-args.test.js | 25 +++++++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/utils/functions/functions.ts b/src/utils/functions/functions.ts index 69650ee1dda..d963cbda1d8 100644 --- a/src/utils/functions/functions.ts +++ b/src/utils/functions/functions.ts @@ -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 } diff --git a/tests/integration/commands/functions-with-args/functions-with-args.test.js b/tests/integration/commands/functions-with-args/functions-with-args.test.js index 84fed497917..a3b90c1c310 100644 --- a/tests/integration/commands/functions-with-args/functions-with-args.test.js +++ b/tests/integration/commands/functions-with-args/functions-with-args.test.js @@ -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' } : {} @@ -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',