Skip to content

Commit c11331f

Browse files

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ module.exports = {
3939
},
4040

4141
url: "",
42+
43+
injectDebugIds: true,
4244
},
4345

4446
configure(context) {
@@ -58,6 +60,19 @@ module.exports = {
5860
}
5961
},
6062

63+
didBuild() {
64+
if (!this.readConfig("injectDebugIds")) {
65+
this.log("SENTRY: Debug ID injection disabled, skipping...");
66+
return;
67+
}
68+
69+
const assetsDir = this.readConfig("assetsDir");
70+
71+
this.log("SENTRY: Injecting Debug IDs...");
72+
this.sentryCliExec("sourcemaps", `inject "${assetsDir}"`);
73+
this.log("SENTRY: Debug IDs injected!");
74+
},
75+
6176
didPrepare() {
6277
const releaseName = `${this.readConfig("appName")}@${this.readConfig(
6378
"revisionKey"

tests/unit/index-nodetest.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ describe('sentry-cli', function () {
8787

8888
assert.equal(typeof plugin.didFail, 'function', 'Implements didFail');
8989
});
90+
91+
it('didBuild', function () {
92+
const plugin = Plugin.createDeployPlugin({ name: 'sentry-cli' });
93+
94+
assert.equal(typeof plugin.didBuild, 'function', 'Implements didBuild');
95+
});
9096
});
9197

9298
describe('configure', function () {
@@ -176,6 +182,47 @@ describe('sentry-cli', function () {
176182

177183
assert.equal(plugin.readConfig('url'), '');
178184
});
185+
186+
it('injectDebugIds', function () {
187+
const plugin = Plugin.createDeployPlugin({ name: 'sentry-cli' });
188+
189+
plugin.beforeHook(this.context);
190+
plugin.configure(this.context);
191+
192+
assert.equal(plugin.readConfig('injectDebugIds'), true);
193+
});
194+
});
195+
});
196+
197+
describe('didBuild', function () {
198+
it('injects debug IDs', function () {
199+
const plugin = Plugin.createDeployPlugin({ name: 'sentry-cli' });
200+
const stub = this.sinon.stub(plugin, '_exec');
201+
202+
plugin.beforeHook(this.context);
203+
plugin.configure(this.context);
204+
plugin.didBuild();
205+
206+
this.sinon.assert.calledWithExactly(
207+
stub,
208+
`${SENTRY_BIN_PATH} --auth-token my-auth-token sourcemaps --org my-org --project my-project inject "${path.join(
209+
'my-dest-dir',
210+
'assets'
211+
)}"`
212+
);
213+
});
214+
215+
it('skips debug ID injection when disabled', function () {
216+
const plugin = Plugin.createDeployPlugin({ name: 'sentry-cli' });
217+
const stub = this.sinon.stub(plugin, '_exec');
218+
219+
this.context.config['sentry-cli'].injectDebugIds = false;
220+
221+
plugin.beforeHook(this.context);
222+
plugin.configure(this.context);
223+
plugin.didBuild();
224+
225+
this.sinon.assert.notCalled(stub);
179226
});
180227
});
181228

0 commit comments

Comments
 (0)