htc 7ca38fdcbb 善行少年PC端首次提交(基础版) 10 mēneši atpakaļ
..
.circleci 7ca38fdcbb 善行少年PC端首次提交(基础版) 10 mēneši atpakaļ
lib 7ca38fdcbb 善行少年PC端首次提交(基础版) 10 mēneši atpakaļ
node_modules 7ca38fdcbb 善行少年PC端首次提交(基础版) 10 mēneši atpakaļ
.babelrc 7ca38fdcbb 善行少年PC端首次提交(基础版) 10 mēneši atpakaļ
.eslintrc 7ca38fdcbb 善行少年PC端首次提交(基础版) 10 mēneši atpakaļ
CHANGELOG.md 7ca38fdcbb 善行少年PC端首次提交(基础版) 10 mēneši atpakaļ
LICENSE.md 7ca38fdcbb 善行少年PC端首次提交(基础版) 10 mēneši atpakaļ
README.md 7ca38fdcbb 善行少年PC端首次提交(基础版) 10 mēneši atpakaļ
package.json 7ca38fdcbb 善行少年PC端首次提交(基础版) 10 mēneši atpakaļ

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 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).

License

MIT, see LICENSE.md for details.