Skip to content

Commit

Permalink
ignore console.error
Browse files Browse the repository at this point in the history
  • Loading branch information
Emilios1995 committed Jun 23, 2016
1 parent faf0685 commit 8e60792
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions babel-preset/transforms/transform-remove-console.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
var template = require('babel-template');
module.exports = function (babel) {
var t = babel.types;
module.exports = function () {
return {
visitor: {
CallExpression(path) {
if (path.get("callee").matchesPattern("console", true)) {
path.node.callee = template(`
(function () {
Array.prototype.slice.call(arguments).forEach(m => (typeof m === 'function') ? m() : m)
})
`)().expression
const callee = path.get("callee")
if (callee.matchesPattern("console", true) && !callee.matchesPattern("console.error")) {
path.node.callee = template(`
(function () {
return null
})
`)().expression
}
}
}
Expand Down

0 comments on commit 8e60792

Please sign in to comment.