Innovenergy_trunk/frontend/node_modules/find-babel-config
Kim 085d7c68ba adding untracked frontend and typescript files 2023-02-21 07:27:20 +01:00
..
.github/workflows adding untracked frontend and typescript files 2023-02-21 07:27:20 +01:00
lib adding untracked frontend and typescript files 2023-02-21 07:27:20 +01:00
.babelrc adding untracked frontend and typescript files 2023-02-21 07:27:20 +01:00
.eslintrc adding untracked frontend and typescript files 2023-02-21 07:27:20 +01:00
CHANGELOG.md adding untracked frontend and typescript files 2023-02-21 07:27:20 +01:00
LICENSE.md adding untracked frontend and typescript files 2023-02-21 07:27:20 +01:00
README.md adding untracked frontend and typescript files 2023-02-21 07:27:20 +01:00
package.json adding untracked frontend and typescript files 2023-02-21 07:27:20 +01:00

README.md

find-babel-config

npm Build Status Coverage Status

Helper function to retrieve the closest Babel configuration from a specific directory.

Installation

npm install --save find-babel-config

Usage

Async

// 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);
    }
});

Sync

// 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 file === null, the config wasn't found. (Also config === null)
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).

License

MIT, see LICENSE.md for details.