Registry / devops / merge-yaml-cli

merge-yaml-cli

JSON →
library1.1.2jsnpmunverified

merge-yaml-cli is a command-line utility for concatenating and merging multiple YAML files into a single output file. It leverages `glob` patterns for flexible input file selection, making it suitable for configuration management in projects with fragmented YAML setups. The package also exposes a Node.js API, allowing programmatic integration into larger JavaScript applications. The current stable version is 1.1.2. Based on its last publish date 8 years ago and limited recent activity, the project appears to be in a maintenance state with infrequent updates. While it provides a core utility, users seeking more advanced merge strategies (e.g., array concatenation vs. deep merging, or specific key-based merging) might need to explore alternatives like `yq` or `yaml-merge` which offer more nuanced control over the merge process.

npm install merge-yaml-cli
INSTALL
IMPORT
SIG · MERGE-YAML-CLI
M
merge-yaml-cli
devopsjavascriptv1.1.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

mergeYaml
const mergeYaml = require('merge-yaml-cli')
import mergeYaml from 'merge-yaml-cli'
This package is CommonJS-only. Direct ESM 'import' syntax is not supported and will result in an error. The `require()` call provides the main API object.
mergeYaml.merge
const mergeYaml = require('merge-yaml-cli'); const result = mergeYaml.merge(['file1.yml', 'file2.yml'])
import { merge } from 'merge-yaml-cli'
The `merge` function is a method on the default CommonJS export. It's not a named export for ESM. Ensure you destructure from the `require`d object if you wish to use it directly.
mergeYaml.on
const mergeYaml = require('merge-yaml-cli'); mergeYaml.on('files', (files) => console.log('Files found:', files))
mergeYaml.addEventListener('files', ...)
The `mergeYaml` object acts as an `EventEmitter` for progress or information. Use the Node.js `on` method, not browser-style `addEventListener`.

Demonstrates global installation and usage of the `merge-yaml-cli` command-line utility to merge multiple YAML files using glob patterns and output the result.

#!/usr/bin/env node // Create dummy YAML files for demonstration const fs = require('fs'); fs.writeFileSync('config/base.yml', 'name: MyApp\nversion: 1.0.0\nenvironment: development'); fs.writeFileSync('config/overrides/prod.yml', 'environment: production\nscale: large\nfeatures:\n - analytics\n - monitoring'); fs.writeFileSync('config/overrides/test.yml', 'environment: testing\nscale: medium\nfeatures:\n - logging'); console.log('Dummy YAML files created.'); console.log('Running merge-yaml-cli...'); // Simulate CLI execution (assuming global install or PATH setup) const { execSync } = require('child_process'); try { execSync('npm i -g merge-yaml-cli', { stdio: 'inherit' }); const cliCommand = 'merge-yaml -i config/base.yml config/overrides/*.yml -o merged.yml'; console.log(`Executing: ${cliCommand}`); execSync(cliCommand, { stdio: 'inherit' }); console.log('\nMerged YAML content:'); console.log(fs.readFileSync('merged.yml', 'utf8')); // Clean up dummy files fs.unlinkSync('config/base.yml'); fs.unlinkSync('config/overrides/prod.yml'); fs.unlinkSync('config/overrides/test.yml'); fs.unlinkSync('merged.yml'); fs.rmdirSync('config/overrides'); fs.rmdirSync('config'); console.log('\nCleanup complete.'); } catch (error) { console.error(`Error during quickstart: ${error.message}`); process.exit(1); }
merge-yaml-cli --version
Debug
Known issues
gotchaThe project's npm page indicates the last publish was 8 years ago, suggesting the package is not actively maintained. This could lead to unaddressed bugs or compatibility issues with newer Node.js versions or YAML specifications. Consider checking GitHub for more recent activity or forks.
fix
Evaluate alternative, more actively maintained YAML merging tools for production environments or critical projects. If using `merge-yaml-cli`, thoroughly test its behavior in your specific environment and Node.js version.
affects: <=1.1.2
breakingThe package uses `glob` for file pattern matching. Changes in `glob`'s behavior or updates to Node.js's file system APIs could potentially alter how file paths are resolved or matched, leading to unexpected merge inputs or outputs. No specific breaking changes are documented for `merge-yaml-cli` itself between versions in the provided context, but `glob` updates could cause subtle issues.
fix
Always test glob patterns thoroughly, especially after Node.js runtime upgrades. Consider explicit file lists if glob behavior becomes unpredictable for critical merges.
affects: >=1.0.0
gotchaThe `merge-yaml-cli` tool performs a simple deep merge, where later files in the input list will overwrite conflicting keys from earlier files. It does not specify advanced merging strategies like array concatenation, which might be desired for certain configurations. For example, if both files define an array for the same key, the array from the later file will replace the earlier one, not combine them.
fix
Understand the merging logic (last-in wins for conflicting keys). If array concatenation or other sophisticated merge strategies are required, consider pre-processing your YAML files or using a different tool (e.g., `yq` or `combine-yaml-cli`) that supports these specific behaviors.
affects: >=1.0.0
gotchaSecurity vulnerabilities in YAML parsing libraries (like `js-yaml`, which this package likely uses) are a known risk, especially when processing untrusted input. Exploits can include arbitrary code execution through unsafe loading of YAML documents. While the Snyk badge indicates known vulnerabilities for the project, the specific details aren't provided in the excerpt.
fix
Avoid using `merge-yaml-cli` to process YAML files from untrusted sources. Regularly check the project's Snyk report or similar vulnerability scanners for updates on its dependencies. For programmatic usage, ensure no unsafe `yaml.load` equivalents are exposed or used internally without proper sanitization if user input is involved.
affects: <=1.1.2
Errors
Common errors & fixes
command not found: merge-yaml
The `merge-yaml-cli` package was installed locally or not installed at all, rather than globally.
fix
Install the package globally using `npm install -g merge-yaml-cli` or `yarn global add merge-yaml-cli`. Alternatively, if installed locally, run it via `npx merge-yaml-cli` or by adding it to your `package.json` scripts.
Error: ENOENT: no such file or directory, open 'nonexistent.yml'
One or more of the input YAML files specified in the command-line arguments or API call does not exist at the given path.
fix
Verify that all file paths and glob patterns are correct and that the files exist relative to the current working directory or as absolute paths. Double-check for typos in file names or directories.
YAMLException: bad indentation of a mapping entry at line X, column Y
One of the input YAML files contains invalid YAML syntax, specifically an indentation error.
fix
Review the indicated YAML file (and line/column number if provided) for incorrect indentation. YAML is very sensitive to whitespace for defining structure. Use a YAML linter or validator to identify and fix syntax errors.
Upgrade
Version history
1.1.2latest on npm
Audit
Dependencies
globrequiredUsed for resolving input file patterns specified in the CLI or API.
js-yamlrequiredCore library for parsing and stringifying YAML content.
Agent activity
2 hits · last 30 days
node
2
Resources
merge-yaml-cli — npm install merge-yaml-cli · libregistry