Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions eslint_temporary_suppressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,6 @@ export default [
'@typescript-eslint/no-unsafe-return': 'off',
},
},
{
files: ['src/commands/functions/functions-build.ts'],
rules: {
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-floating-promises': 'off',
},
},
{
files: ['src/commands/functions/functions-create.ts'],
rules: {
Expand Down
6 changes: 3 additions & 3 deletions src/commands/functions/functions-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type BaseCommand from '../base-command.js'
export const functionsBuild = async (options: OptionValues, command: BaseCommand) => {
const { config } = command.netlify

const src = options.src || config.build.functionsSource
const src = ('src' in options && typeof options.src === 'string' ? options.src : null) ?? config.build.functionsSource
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here--this will now allow an empty string, won't it?

const dst = getFunctionsDir({ options, config })

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

await mkdir(dst, { recursive: true })

log(`${NETLIFYDEVLOG} Building functions`)

zipFunctions(src, dst)
await zipFunctions(src, dst)
log(`${NETLIFYDEVLOG} Functions built to `, dst)
}
6 changes: 5 additions & 1 deletion src/utils/functions/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ export const getFunctionsDir = (
options: OptionValues
},
defaultValue?: string,
) => options.functions || config.dev?.functions || config.functionsDirectory || defaultValue
): string | undefined =>
('functions' in options && typeof options.functions === 'string' ? options.functions : null) ??
config.dev?.functions ??
config.functionsDirectory ??
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this a behavioral change? Won't this now allow config.dev.functions and config.functionsDirectory to be an empty string? Or do we sanitize empty strings out somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how you could even end up with an empty string, other than explicitly using "" in your netlify.toml or something... 🤔

I feel like it isn't worth the added complexity to this line to support ignoring hypothetical empty strings here, but in the interest of limiting behavioural changes I'll go ahead and add the conditions 🙈.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's worth the added complexity here or the change risk, however low that risk is (you're still adding in new behavior by checking for strings with only whitespace in them). I don't think that bundling it in with a clear and totally unrelated bug is really the way to go about this change, either.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that trim() wouldn't be controversial, but alright, I've reverted that too.

defaultValue

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