peach a19a732be8 commit message | hace 2 años | |
---|---|---|
.. | ||
.circleci | hace 2 años | |
lib | hace 2 años | |
node_modules | hace 2 años | |
.babelrc | hace 2 años | |
.eslintrc | hace 2 años | |
CHANGELOG.md | hace 2 años | |
LICENSE.md | hace 2 años | |
README.md | hace 2 años | |
package.json | hace 2 años |
Helper function to retrieve the closest Babel configuration from a specific directory.
npm install --save find-babel-config
// directory can be an absolute or relative path
// If it's a relative path, it is relative to the current working directory (process.cwd())
const directory = 'src';
findBabelConfig(directory).then(({ file, config }) => {
if (file) {
// file is the file in which the config is found
console.log(file);
// config is a JS plain object with the babel config
console.log(config);
}
});
// directory can be an absolute or relative path
// If it's a relative path, it is relative to the current working directory (process.cwd())
const directory = 'src';
const { file, config } = findBabelConfig.sync(directory);
// if c === null, the config wasn't found
if (file) {
// file is the file in which the config is found
console.log(file);
// config is a JS plain object with the babel config
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)
.
MIT, see LICENSE.md for details.