Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use correct paths when deploying edge functions on Windows #4760

Merged
merged 1 commit into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 2 additions & 3 deletions src/lib/edge-functions/deploy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// @ts-check
const { stat } = require('fs').promises
const path = require('path')

const { getPathInProject } = require('../settings')

Expand All @@ -10,7 +9,7 @@ const distPath = getPathInProject([EDGE_FUNCTIONS_FOLDER])

const deployFileNormalizer = (file) => {
const isEdgeFunction = file.root === distPath
const normalizedPath = isEdgeFunction ? path.join(PUBLIC_URL_PATH, file.normalizedPath) : file.normalizedPath
Copy link
Member Author

Choose a reason for hiding this comment

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

This effectively a URL, not a filesystem path. So it needs to use the UNIX format regardless of the host platform.

const normalizedPath = isEdgeFunction ? `${PUBLIC_URL_PATH}/${file.normalizedPath}` : file.normalizedPath

return {
...file,
Expand All @@ -32,7 +31,7 @@ const getDistPathIfExists = async () => {
}
}

const isEdgeFunctionFile = (filePath) => filePath.startsWith(`${PUBLIC_URL_PATH}${path.sep}`)
const isEdgeFunctionFile = (filePath) => filePath.startsWith(`${PUBLIC_URL_PATH}/`)

module.exports = {
deployFileNormalizer,
Expand Down
3 changes: 1 addition & 2 deletions tests/integration/210.command.deploy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ if (process.env.NETLIFY_TEST_DISABLE_LIVE !== 'true') {
})
})

// TODO: Re-add when feature flag is no longer needed.
test.serial.skip('should deploy Edge Functions when directory exists', async (t) => {
test.serial('should deploy Edge Functions when directory exists', async (t) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

This test would've caught this, but we never enabled it after the public beta. 😞

await withSiteBuilder('site-with-public-folder', async (builder) => {
const content = '<h1>loud</h1>'
builder
Expand Down