Skip to content
This repository has been archived by the owner on Jan 12, 2021. It is now read-only.

Commit

Permalink
fix: Remove overwrite from payload when false
Browse files Browse the repository at this point in the history
Fixes #23
  • Loading branch information
bengourley committed Aug 1, 2018
1 parent 03481eb commit 8dedca1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,12 @@ function transformOptions(options) {
options.tempDir = fs.mkdtempSync('bugsnag-sourcemaps');
return transformSourcesMap(options);
}
if (!options.overwrite) {
// the presence of any value for this flag causes the API to interpret it as
// true, so once it has been parsed and set remove it from the payload entirely
// if false(y)
delete options.overwrite
}
return options;
}

Expand Down
10 changes: 10 additions & 0 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const stripProjectRoot = require('./index').stripProjectRoot
const upload = require('./index').upload
const validateOptions = require('./index').validateOptions
const transformOptions = require('./index').transformOptions

test('upload function exists', () => {
expect(typeof upload).toBe('function');
Expand Down Expand Up @@ -71,3 +72,12 @@ describe('validateOptions', () => {
}).toThrow('You must provide a path to the source map you want to upload.');
});
});

describe('transformOptions', () => {
test('removes options.overwrite when false', () => {
expect(transformOptions({ overwrite: false })).toEqual({});
});
test('does not remove options.overwrite when true', () => {
expect(transformOptions({ overwrite: true })).toEqual({ overwrite: true });
});
});

0 comments on commit 8dedca1

Please sign in to comment.