-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(sourcemaps): Write package manager command instead of object to p…
…ackage.json (#453) fix a bug in our Sentry-CLI flow when we printed the package manager object (introduced in #417) to the package.json instead of the package manager's run command
- Loading branch information
Showing
4 changed files
with
80 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import * as fs from 'fs'; | ||
|
||
import { addSentryCommandToBuildCommand } from '../../../src/sourcemaps/tools/sentry-cli'; | ||
|
||
import * as packageManagerHelpers from '../../../src/utils/package-manager'; | ||
|
||
const writeFileSpy = jest | ||
.spyOn(fs.promises, 'writeFile') | ||
.mockImplementation(() => Promise.resolve()); | ||
|
||
jest.mock('@clack/prompts', () => { | ||
return { | ||
log: { | ||
info: jest.fn(), | ||
success: jest.fn(), | ||
}, | ||
confirm: jest.fn().mockResolvedValue(true), | ||
isCancel: jest.fn().mockReturnValue(false), | ||
}; | ||
}); | ||
|
||
describe('addSentryCommandToBuildCommand', () => { | ||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
it.each([ | ||
[ | ||
packageManagerHelpers.NPM, | ||
packageManagerHelpers.PNPM, | ||
packageManagerHelpers.YARN, | ||
packageManagerHelpers.BUN, | ||
], | ||
])('adds the cli command to the script command (%s)', async (_, pacMan) => { | ||
jest | ||
.spyOn(packageManagerHelpers, 'detectPackageManger') | ||
.mockReturnValue(pacMan); | ||
const packageJson = { | ||
scripts: { | ||
build: 'tsc', | ||
}, | ||
version: '1.0.0', | ||
}; | ||
await addSentryCommandToBuildCommand(packageJson); | ||
expect(writeFileSpy).toHaveBeenCalledWith( | ||
expect.stringContaining('package.json'), | ||
expect.stringContaining( | ||
`tsc && ${pacMan.runScriptCommand} sentry:sourcemaps`, | ||
), | ||
); | ||
}); | ||
}); |