-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
executable file
·37 lines (27 loc) · 684 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env node
'use strict'
const yaml = require('yamljs')
const objectPath = require('object-path')
const stdin = process.stdin
const stdout = process.stdout
let content = ''
const pathToPrune = process.argv[2]
if (!pathToPrune) {
console.error(`Missing argument "path".
Usage:
${process.argv[0]} ${process.argv[1]} <path>
`)
process.exit(1)
}
stdin.resume()
stdin.setEncoding('utf8')
stdin.on('data', function (chunk) {
content += chunk
})
stdin.on('end', function () {
const parsedData = yaml.parse(content)
objectPath.del(parsedData, pathToPrune)
const outputYaml = yaml.stringify(parsedData, 8)
stdout.write(outputYaml)
stdout.write('\n')
})