Skip to content

Commit

Permalink
fix(nuxt): Use absolute path for client config
Browse files Browse the repository at this point in the history
  • Loading branch information
s1gr1d committed Sep 25, 2024
1 parent 4ce48e9 commit a3b5dca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/nuxt/src/vite/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ export function findDefaultSdkInitFile(type: 'server' | 'client'): string | unde

const filePath = filePaths.find(filename => fs.existsSync(filename));

return filePath ? path.basename(filePath) : undefined;
return filePath ? filePath : undefined;
}
12 changes: 6 additions & 6 deletions packages/nuxt/test/vite/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ describe('findDefaultSdkInitFile', () => {
});

it.each(['ts', 'js', 'mjs', 'cjs', 'mts', 'cts'])(
'should return the server file with .%s extension if it exists',
'should return the server file path with .%s extension if it exists',
ext => {
vi.spyOn(fs, 'existsSync').mockImplementation(filePath => {
return !(filePath instanceof URL) && filePath.includes(`sentry.server.config.${ext}`);
});

const result = findDefaultSdkInitFile('server');
expect(result).toBe(`sentry.server.config.${ext}`);
expect(result).toMatch(`packages/nuxt/sentry.server.config.${ext}`);
},
);

it.each(['ts', 'js', 'mjs', 'cjs', 'mts', 'cts'])(
'should return the client file with .%s extension if it exists',
'should return the client file path with .%s extension if it exists',
ext => {
vi.spyOn(fs, 'existsSync').mockImplementation(filePath => {
return !(filePath instanceof URL) && filePath.includes(`sentry.client.config.${ext}`);
});

const result = findDefaultSdkInitFile('client');
expect(result).toBe(`sentry.client.config.${ext}`);
expect(result).toMatch(`packages/nuxt/sentry.client.config.${ext}`);
},
);

Expand All @@ -47,7 +47,7 @@ describe('findDefaultSdkInitFile', () => {
expect(result).toBeUndefined();
});

it('should return the server config file if server.config and instrument exist', () => {
it('should return the server config file path if server.config and instrument exist', () => {
vi.spyOn(fs, 'existsSync').mockImplementation(filePath => {
return (
!(filePath instanceof URL) &&
Expand All @@ -56,6 +56,6 @@ describe('findDefaultSdkInitFile', () => {
});

const result = findDefaultSdkInitFile('server');
expect(result).toBe('sentry.server.config.js');
expect(result).toMatch('packages/nuxt/sentry.server.config.js');
});
});

0 comments on commit a3b5dca

Please sign in to comment.