Skip to content

Commit adca0f5

Browse files
authored
fix(nuxt): Only use filename with file extension from command (#15445)
The Nuxt SDK also uses the preview command to determine where to put the Sentry top-level import. Like this: `node .output/server/index.mjs` (would add Sentry to `index.mjs`) However, the function to get the file name also used folder names without file extensions which led to Sentry not being included at the top of the index file. This was a problem in e.g. Azure as the command is the following: `npx @azure/static-web-apps-cli start ./public --api-location ./server`
1 parent d42d04f commit adca0f5

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

packages/nuxt/src/vite/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function findDefaultSdkInitFile(type: 'server' | 'client'): string | unde
3030
* Extracts the filename from a node command with a path.
3131
*/
3232
export function getFilenameFromNodeStartCommand(nodeCommand: string): string | null {
33-
const regex = /[^/\\]+$/;
33+
const regex = /[^/\\]+\.[^/\\]+$/;
3434
const match = nodeCommand.match(regex);
3535
return match ? match[0] : null;
3636
}

packages/nuxt/test/vite/utils.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ describe('getFilenameFromPath', () => {
107107
const filename = getFilenameFromNodeStartCommand(path);
108108
expect(filename).toBeNull();
109109
});
110+
111+
it('should return null for commands without file extensions', () => {
112+
const path = 'npx @azure/static-web-apps-cli start .output/public --api-location .output/server';
113+
const filename = getFilenameFromNodeStartCommand(path);
114+
expect(filename).toBeNull();
115+
});
110116
});
111117

112118
describe('removeSentryQueryFromPath', () => {

0 commit comments

Comments
 (0)