Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
find-babel-config
Advanced tools
Package description
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.
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.');
}
babel-find is a package similar to find-babel-config that also helps in locating Babel configuration files. It may differ in the specific methods it provides or the way it handles the search process.
cosmiconfig is a more general configuration file finder that can be used to find Babel configurations among other types of configurations. It is more flexible and supports various file formats and custom loaders, which makes it a more versatile choice compared to find-babel-config.
Changelog
2.0.0 (2023-01-09)
<a name="1.2.0"></a>
Readme
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 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)
.
MIT, see LICENSE.md for details.
FAQs
Find the closest babel config based on a directory
The npm package find-babel-config receives a total of 2,117,080 weekly downloads. As such, find-babel-config popularity was classified as popular.
We found that find-babel-config demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.