merge-yaml-cli
Advanced tools
Comparing version 1.0.5 to 1.1.0
@@ -6,2 +6,6 @@ # Change Log | ||
## [1.1.0] - 2017-05-29 | ||
- Update dependencies | ||
- Add a Node.js API to require the module, give it an array of globs and return a YAML string | ||
## [1.0.5] - 2016-12-03 | ||
@@ -8,0 +12,0 @@ - Update dependencies |
37
index.js
@@ -1,35 +0,18 @@ | ||
#!/usr/bin/env node | ||
const fs = require('fs') | ||
const os = require('os') | ||
const glob = require('glob') | ||
const mergeYaml = require('merge-yaml') | ||
const jsYaml = require('js-yaml') | ||
const EventEmitter = require('events') | ||
const args = require('yargs') | ||
.usage('Usage: $0 <options>') | ||
.example('$0 -i one.yml two/*.yml -o out.yml') | ||
.array('i') | ||
.alias('i', 'inputs') | ||
.describe('i', 'Input files specified as glob file patterns') | ||
.demand('i') | ||
.string('o') | ||
.alias('o', 'output') | ||
.describe('o', 'Output file') | ||
.demand('o') | ||
.strict() | ||
.argv | ||
class YamlMerger extends EventEmitter { | ||
merge (sources) { | ||
const files = [].concat.apply([], sources.map(g => glob.sync(g, {nodir: true}))) | ||
const files = [].concat.apply([], args.inputs.map(g => glob.sync(g, {nodir: true}))) | ||
this.emit('files', files) | ||
console.log('Merging files:') | ||
console.log(files.join(os.EOL), os.EOL) | ||
const mergeResult = mergeYaml(files) | ||
const mergeResult = mergeYaml(files) | ||
return jsYaml.safeDump(mergeResult) | ||
} | ||
}; | ||
console.log('Writing:') | ||
console.log(args.output) | ||
fs.writeFileSync(args.output, jsYaml.safeDump(mergeResult)) | ||
console.log(os.EOL) | ||
console.log('Finished merge!') | ||
module.exports = new YamlMerger() |
{ | ||
"name": "merge-yaml-cli", | ||
"version": "1.0.5", | ||
"version": "1.1.0", | ||
"description": "CLI utility for merging YAML files", | ||
"main": "index.js", | ||
"bin": { | ||
"merge-yaml": "./index.js" | ||
"merge-yaml": "./cli.js" | ||
}, | ||
@@ -31,7 +32,7 @@ "keywords": [ | ||
"merge-yaml": "^1.0.0", | ||
"yargs": "^6.5.0" | ||
"yargs": "^8.0.1" | ||
}, | ||
"devDependencies": { | ||
"standard": "^8.6.0" | ||
"standard": "^10.0.0" | ||
} | ||
} |
# merge-yaml-cli | ||
[![JavaScript Style Guide](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard) | ||
[![Known Vulnerabilities](https://snyk.io/test/github/brainsiq/merge-yaml-cli/ac54a80e5f7f1648aecc380c7aea470f49f1ccef/badge.svg)](https://snyk.io/test/github/brainsiq/merge-yaml-cli/ac54a80e5f7f1648aecc380c7aea470f49f1ccef) [![Standard - JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](http://standardjs.com/) | ||
[![CircleCI](https://circleci.com/gh/brainsiq/merge-yaml-cli/tree/master.svg?style=shield&circle-token=077fdc5153f1faebffa5e687a44369759c6a820d)](https://circleci.com/gh/brainsiq/merge-yaml-cli/tree/master) | ||
[![CircleCI](https://circleci.com/gh/brainsiq/merge-yaml-cli/tree/master.svg?style=svg&circle-token=077fdc5153f1faebffa5e687a44369759c6a820d)](https://circleci.com/gh/brainsiq/merge-yaml-cli/tree/master) [![Known Vulnerabilities](https://snyk.io/test/github/brainsiq/merge-yaml-cli/ac54a80e5f7f1648aecc380c7aea470f49f1ccef/badge.svg)](https://snyk.io/test/github/brainsiq/merge-yaml-cli/ac54a80e5f7f1648aecc380c7aea470f49f1ccef) | ||
[![NPM](https://nodei.co/npm/merge-yaml-cli.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/merge-yaml-cli/) | ||
@@ -16,2 +17,12 @@ A simple CLI wrapper around [merge-yaml](https://www.npmjs.com/package/merge-yaml) using [glob](https://www.npmjs.com/package/glob) patterns to specify input files. | ||
#### Node.js API | ||
``` | ||
const mergeYaml = require('merge-yaml-cli') | ||
mergeYaml.on('files', console.log('Files found: ', files)) | ||
const result = mergeYaml.merge(['example.yml', 'includes/*.yml']) | ||
``` | ||
#### Tests | ||
@@ -18,0 +29,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
54592
14
40
32
+ Addedansi-regex@3.0.1(transitive)
+ Addedcamelcase@4.1.0(transitive)
+ Addedcross-spawn@5.1.0(transitive)
+ Addedexeca@0.7.0(transitive)
+ Addedfind-up@2.1.0(transitive)
+ Addedget-stream@3.0.0(transitive)
+ Addedis-fullwidth-code-point@2.0.0(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedload-json-file@2.0.0(transitive)
+ Addedlocate-path@2.0.0(transitive)
+ Addedlru-cache@4.1.5(transitive)
+ Addedmem@1.1.0(transitive)
+ Addedmimic-fn@1.2.0(transitive)
+ Addednpm-run-path@2.0.2(transitive)
+ Addedos-locale@2.1.0(transitive)
+ Addedp-finally@1.0.0(transitive)
+ Addedp-limit@1.3.0(transitive)
+ Addedp-locate@2.0.0(transitive)
+ Addedp-try@1.0.0(transitive)
+ Addedpath-exists@3.0.0(transitive)
+ Addedpath-key@2.0.1(transitive)
+ Addedpath-type@2.0.0(transitive)
+ Addedpseudomap@1.0.2(transitive)
+ Addedread-pkg@2.0.0(transitive)
+ Addedread-pkg-up@2.0.0(transitive)
+ Addedshebang-command@1.2.0(transitive)
+ Addedshebang-regex@1.0.0(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedstring-width@2.1.1(transitive)
+ Addedstrip-ansi@4.0.0(transitive)
+ Addedstrip-bom@3.0.0(transitive)
+ Addedstrip-eof@1.0.0(transitive)
+ Addedwhich@1.3.1(transitive)
+ Addedwhich-module@2.0.1(transitive)
+ Addedyallist@2.1.2(transitive)
+ Addedyargs@8.0.2(transitive)
+ Addedyargs-parser@7.0.0(transitive)
- Removedcamelcase@3.0.0(transitive)
- Removedfind-up@1.1.2(transitive)
- Removedis-utf8@0.2.1(transitive)
- Removedload-json-file@1.1.0(transitive)
- Removedos-locale@1.4.0(transitive)
- Removedpath-exists@2.1.0(transitive)
- Removedpath-type@1.1.0(transitive)
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)
- Removedread-pkg@1.1.0(transitive)
- Removedread-pkg-up@1.0.1(transitive)
- Removedstrip-bom@2.0.0(transitive)
- Removedwhich-module@1.0.0(transitive)
- Removedyargs@6.6.0(transitive)
- Removedyargs-parser@4.2.1(transitive)
Updatedyargs@^8.0.1