babel-plugin-inline-replace-variables
Advanced tools
Comparing version 1.2.0 to 1.2.1
{ | ||
"name": "babel-plugin-inline-replace-variables", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "babel plugin to inline replace variables", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -13,5 +13,11 @@ /** | ||
} | ||
if (path.parent.type === 'ClassMethod') { | ||
return; | ||
} | ||
if (path.isPure()) { | ||
return; | ||
} | ||
if (!state.opts.hasOwnProperty(path.node.name)) { | ||
return; | ||
} | ||
const replacement = state.opts[path.node.name] | ||
@@ -18,0 +24,0 @@ if (replacement !== undefined) { |
@@ -84,1 +84,51 @@ /** | ||
}); | ||
describe('ignore class methods', () => { | ||
describe(`transform`, () => { | ||
it(`__SERVER__ should NOT be replaced`, () => { | ||
babel.transform(` | ||
export default class Hello { | ||
__SERVER__(foo) { | ||
this.foo = foo; | ||
} | ||
} | ||
`, { | ||
plugins: [[plugin, { | ||
__SERVER__: true, | ||
__VERSION__: "v1.2.3" | ||
}]] | ||
}).code | ||
.should.be.equal(` | ||
export default class Hello { | ||
__SERVER__(foo) { | ||
this.foo = foo; | ||
} | ||
}`) | ||
}); | ||
}); | ||
}); | ||
describe('object own properties', () => { | ||
describe(`transform`, () => { | ||
it(`only own properties should be replaced`, () => { | ||
babel.transform(` | ||
var foo = constructor; | ||
var bar = isPrototypeOf; | ||
var baz = __SERVER__; | ||
`, { | ||
plugins: [[plugin, { | ||
__SERVER__: true, | ||
__VERSION__: "v1.2.3" | ||
}]] | ||
}).code | ||
.should.be.equal(` | ||
var foo = constructor; | ||
var bar = isPrototypeOf; | ||
var baz = true;`) | ||
}); | ||
}); | ||
}); |
7692
189