Created
November 23, 2015 18:43
-
-
Save jon49/32dbe0fae971c3e7d39b to your computer and use it in GitHub Desktop.
Use yaml for npm command line scripts and merge with package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import r = require('ramda') | |
import yaml = require('js-yaml') | |
import {readFile, writeFile} from 'fs' | |
var package = require('../package.json') | |
readFile('../scripts.yml', 'utf-8', (err, file) => { | |
if (err) { | |
console.log('Error reading scripts.yml', err) | |
return process.exit(1) | |
} | |
const | |
scripts = yaml.load(file), | |
combined = r.merge(package, scripts) | |
writeFile('./package.json', JSON.stringify(combined, null, ' ').replace(/\\n/g, ' '), err => { | |
if (err) { | |
console.error('There was an error writing to package.json!', err) | |
return process.exit(1) | |
} | |
process.exit(0) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment