Skip to content

Commit 6755271

Browse files
authored
Merge pull request #77 from ember-cli/remove-error
Remove requirement for 'debugTools' options
2 parents 9e2d5ff + fceb9bf commit 6755271

File tree

7 files changed

+56
-10
lines changed

7 files changed

+56
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ options.
1515
{
1616
plugins: [
1717
['babel-debug-macros', {
18-
// @required
18+
// @optional
1919
debugTools: {
2020
isDebug: true,
2121
source: 'debug-tools',
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Bar from 'bar';
2+
import Baz from 'baz';
3+
4+
export default class extends Bar {
5+
static create() {
6+
return new Baz(new this());
7+
}
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Bar from 'bar';
2+
import Baz from 'baz';
3+
export default class extends Bar {
4+
static create() {
5+
return new Baz(new this());
6+
}
7+
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Bar from 'bar';
2+
import Baz from 'baz';
3+
4+
export default class extends Bar {
5+
static create() {
6+
return new Baz(new this());
7+
}
8+
}

src/utils/normalize-options.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
const gt = require('semver').gt;
44

55
function parseDebugTools(options) {
6-
let debugTools = options.debugTools || {};
7-
8-
if (!debugTools) {
9-
throw new Error('You must specify `debugTools.source`');
10-
}
6+
let debugTools = options.debugTools || {
7+
isDebug: false,
8+
source: '',
9+
assertPredicateIndex: undefined,
10+
};
1111

1212
let isDebug = debugTools.isDebug;
1313
let debugToolsImport = debugTools.source;
@@ -17,10 +17,6 @@ function parseDebugTools(options) {
1717
isDebug = options.envFlags.flags.DEBUG;
1818
}
1919

20-
if (isDebug === undefined) {
21-
throw new Error('You must specify `debugTools.isDebug`');
22-
}
23-
2420
return {
2521
isDebug,
2622
debugToolsImport,

tests/create-tests.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ function createTests(options) {
8080
h.generateTest('log-expansion');
8181
});
8282

83+
describe('Debug macros idempotnency', function() {
84+
let h = transformTestHelper({
85+
presets,
86+
plugins: [[DebugToolsPlugin]],
87+
});
88+
89+
h.generateTest('missing-debug-tools-options');
90+
});
91+
8392
describe('foreign debug imports', function() {
8493
let h = transformTestHelper({
8594
presets,

tests/normalize-options-test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,23 @@ describe('normalizeOptions', function() {
99
Object.assign(console, originalConsole);
1010
});
1111

12+
it('does not require the `debugTools` options', function() {
13+
let actual = normalizeOptions({});
14+
15+
let expected = {
16+
debugTools: {
17+
debugToolsImport: '',
18+
assertPredicateIndex: undefined,
19+
isDebug: false,
20+
},
21+
externalizeHelpers: undefined,
22+
flags: {},
23+
svelte: undefined,
24+
};
25+
26+
expect(actual).toEqual(expected);
27+
});
28+
1229
it('converts "old style" options into the newer style (with deprecation)', function() {
1330
let warnings = [];
1431
console.warn = warning => warnings.push(warning); // eslint-disable-line

0 commit comments

Comments
 (0)