modify-babel-preset
Advanced tools
Comparing version 1.1.3 to 1.2.0
@@ -20,5 +20,6 @@ var path = require('path'), | ||
modifications = modifications || {}; | ||
var nameDrops = modifications.nameDrops!==false; | ||
if (typeof preset==='string') { | ||
if (!preset.match(/^babel-preset-/)) { | ||
if (!preset.match(/(^babel-preset-|\/)/)) { | ||
try { | ||
@@ -78,2 +79,4 @@ preset = relative.resolve('babel-preset-'+preset); | ||
Object.keys(modifications).forEach(function(key) { | ||
if (key==='nameDrops') return; | ||
var value = modifications[key], | ||
@@ -89,3 +92,5 @@ index = indexOf(plugins, key); | ||
var p = getPlugin(key); | ||
plugin._original_name = key; | ||
if (nameDrops) { | ||
p._original_name = key; | ||
} | ||
if (value!==true) { | ||
@@ -92,0 +97,0 @@ p = [p].concat(value); |
{ | ||
"name": "modify-babel-preset", | ||
"version": "1.1.3", | ||
"version": "1.2.0", | ||
"description": "Create a modified babel preset based on an an existing preset.", | ||
"main": "index.js", | ||
"scripts": { | ||
"prepublish": "NODE_ENV=development npm test", | ||
"test": "mocha test/**" | ||
@@ -8,0 +9,0 @@ }, |
@@ -27,2 +27,3 @@ var expect = require('chai').expect, | ||
var out = modifyBabelPreset('es2015', { | ||
nameDrops: false, | ||
'transform-react-jsx': true | ||
@@ -35,2 +36,3 @@ }); | ||
var out = modifyBabelPreset('es2015', { | ||
nameDrops: false, | ||
'transform-react-jsx': { jsxPragma:'h' } | ||
@@ -42,2 +44,30 @@ }); | ||
}); | ||
it('should work recursively', function() { | ||
var one = require('./fixtures/one'); | ||
expect(one.plugins).to.deep.equal( es2015Preset.plugins.concat([ | ||
[jsx, { jsxPragma:'h' }] | ||
]).map(function(p) { | ||
if (p===transform || p[0]===transform) { | ||
return [transform, { loose:true }]; | ||
} | ||
return p; | ||
}) ); | ||
var two = require('./fixtures/two'); | ||
two.plugins.forEach(function(p) { | ||
var f = Array.isArray(p) ? p[0] : p; | ||
delete p._original_name; | ||
}); | ||
delete transform._original_name; | ||
delete jsx._original_name; | ||
var target = es2015Preset.plugins.concat([ | ||
[jsx, { jsxPragma:'z' }] | ||
]); | ||
target.splice(17, 1); | ||
expect(two.plugins).to.deep.equal(target); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7466
8
168