Skip to content

Commit e3b04e5

Browse files
authored
fix: await zipFunctions() in functions build (#7180)
* fix: fully wait for build in `functions:build` cmd * build: fix suppressed eslint errors
1 parent e7cd9e5 commit e3b04e5

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

eslint_temporary_suppressions.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,14 +212,6 @@ export default [
212212
'@typescript-eslint/no-unsafe-return': 'off',
213213
},
214214
},
215-
{
216-
files: ['src/commands/functions/functions-build.ts'],
217-
rules: {
218-
'@typescript-eslint/no-unsafe-assignment': 'off',
219-
'@typescript-eslint/no-unsafe-argument': 'off',
220-
'@typescript-eslint/no-floating-promises': 'off',
221-
},
222-
},
223215
{
224216
files: ['src/commands/functions/functions-create.ts'],
225217
rules: {

src/commands/functions/functions-build.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import type BaseCommand from '../base-command.js'
1010
export const functionsBuild = async (options: OptionValues, command: BaseCommand) => {
1111
const { config } = command.netlify
1212

13-
const src = options.src || config.build.functionsSource
13+
const src =
14+
('src' in options && typeof options.src === 'string' && options.src.trim().length > 0 ? options.src : null) ??
15+
config.build.functionsSource
1416
const dst = getFunctionsDir({ options, config })
1517

1618
if (src === dst) {
@@ -27,13 +29,13 @@ export const functionsBuild = async (options: OptionValues, command: BaseCommand
2729
log(
2830
`${NETLIFYDEVERR} Error: You must specify a destination functions folder with a --functions flag or a functions field in your config`,
2931
)
30-
exit(1)
32+
return exit(1)
3133
}
3234

3335
await mkdir(dst, { recursive: true })
3436

3537
log(`${NETLIFYDEVLOG} Building functions`)
3638

37-
zipFunctions(src, dst)
39+
await zipFunctions(src, dst)
3840
log(`${NETLIFYDEVLOG} Functions built to `, dst)
3941
}

src/utils/functions/functions.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import type { NormalizedCachedConfigConfig } from '../command-helpers.js'
1010
export const INTERNAL_FUNCTIONS_FOLDER = 'functions-internal'
1111
export const SERVE_FUNCTIONS_FOLDER = 'functions-serve'
1212

13+
const isNonEmptyString = (s: unknown): s is string => typeof s === 'string' && s.length > 0
14+
1315
/**
1416
* retrieves the function directory out of the flags or config
1517
*/
@@ -22,7 +24,11 @@ export const getFunctionsDir = (
2224
options: OptionValues
2325
},
2426
defaultValue?: string,
25-
) => options.functions || config.dev?.functions || config.functionsDirectory || defaultValue
27+
): string | undefined =>
28+
('functions' in options && isNonEmptyString(options.functions) ? options.functions : null) ??
29+
(isNonEmptyString(config.dev?.functions) ? config.dev.functions : null) ??
30+
(isNonEmptyString(config.functionsDirectory) ? config.functionsDirectory : null) ??
31+
defaultValue
2632

2733
export const getFunctionsManifestPath = async ({ base, packagePath = '' }: { base: string; packagePath?: string }) => {
2834
const path = resolve(base, packagePath, getPathInProject(['functions', 'manifest.json']))

0 commit comments

Comments
 (0)