Socket
Socket
Sign inDemoInstall

find-babel-config

Package Overview
Dependencies
1
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    find-babel-config

Find the closest babel config based on a directory


Version published
Maintainers
1
Install size
50.7 kB
Created

Package description

What is find-babel-config?

The find-babel-config npm package is a utility that helps in finding Babel configuration files in a project. It searches for Babel configuration files (.babelrc, .babelrc.js, babel.config.js) in the directory you specify and upwards through the directory tree until it finds a configuration file.

What are find-babel-config's main functionalities?

find Babel configuration

This feature allows you to find the Babel configuration file and its contents. The function returns a promise that resolves with an object containing the path to the configuration file and its contents if found.

const findBabelConfig = require('find-babel-config');

(async () => {
  const { file, config } = await findBabelConfig('./path/to/project');
  if (file) {
    console.log(`Found Babel config at: ${file}`);
    console.log('Config contents:', config);
  } else {
    console.log('No Babel config found.');
  }
})();

synchronous find

This feature provides a synchronous method to find the Babel configuration file. It returns an object with the path to the configuration file and its contents if found.

const findBabelConfig = require('find-babel-config');

const { file, config } = findBabelConfig.sync('./path/to/project');
if (file) {
  console.log(`Found Babel config at: ${file}`);
  console.log('Config contents:', config);
} else {
  console.log('No Babel config found.');
}

Other packages similar to find-babel-config

Changelog

Source

0.1.1 (2016-07-10)

Bug Fixes

  • release: Ignore src/ but not lib/ for npm (2588adf)

<a name="0.1.0"></a>

Readme

Source

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

// 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 c = findBabelConfig(directory);
// if c === null, the config wasn't found
if (c) {
    const { file, config } = c;
    // 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.

Keywords

FAQs

Last updated on 10 Jul 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc