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

Commit

Permalink
Merge 88a2c65 into 08ee643
Browse files Browse the repository at this point in the history
  • Loading branch information
bengourley committed Aug 1, 2018
2 parents 08ee643 + 88a2c65 commit 0c8afc2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ const cli = meow(`
string: [
'app-version',
],
boolean: [
'overwrite',
'upload-node-modules',
'upload-sources',
'add-wildcard-prefix',
],
});

const conf = {
Expand Down
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,12 @@ function transformOptions(options) {
options.tempDir = fs.mkdtempSync(path.join(os.tmpdir(), '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 0c8afc2

Please sign in to comment.