find-babel-config
Helper function to retrieve the closest Babel configuration from a specific directory.
Installation
npm install --save find-babel-config
Usage
Async
const directory = 'src';
findBabelConfig(directory).then(({ file, config }) => {
if (file) {
console.log(file);
console.log(config);
}
});
Sync
const directory = 'src';
const { file, config } = findBabelConfig.sync(directory);
if (file) {
console.log(file);
console.log(config);
}
A second parameter can be given to findBabelConfig
, it specifies the depth
of search. By default, this value is Infinity
but you can set the value you want: findBabelConfig('src', 10)
.
License
MIT, see LICENSE.md for details.