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(nuxt): Use absolute path for client config #13798

Merged
merged 3 commits into from
Sep 26, 2024
Merged
Changes from 1 commit
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
Next Next commit
fix(nuxt): Use absolute path for client config
s1gr1d committed Sep 25, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit a3b5dcabb8d1e1c6c1662d9fedeee4377a774a1b
2 changes: 1 addition & 1 deletion packages/nuxt/src/vite/utils.ts
Original file line number Diff line number Diff line change
@@ -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;
Copy link
Member

Choose a reason for hiding this comment

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

l: doesn't find() already return undefined? If so we probably don't need the ternary here

}
12 changes: 6 additions & 6 deletions packages/nuxt/test/vite/utils.test.ts
Original file line number Diff line number Diff line change
@@ -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}`);
},
);

@@ -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) &&
@@ -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');
});
});