find-babel-config

Find the closest babel config based on a directory

MIT 12 个版本
安装
npm install find-babel-config
yarn add find-babel-config
pnpm add find-babel-config
bun add find-babel-config
README

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.

版本列表
2.1.2 2024-09-02
2.1.1 2024-04-17
2.1.0 2024-04-17
2.0.0 2023-01-09
1.2.2 2024-04-25
1.2.1 2024-04-17
1.2.0 2019-03-04
1.1.0 2017-05-08
1.0.1 2016-08-20
1.0.0 2016-08-06
0.1.1 2016-07-10
0.1.0 2016-07-10