Created
August 2, 2021 07:11
-
-
Save makoru-hikage/6f18ae5a4c06936a6ca15fb8d21b4e1c to your computer and use it in GitHub Desktop.
A script for Node: changes a Rescript project's bsconfig.json's "package-specs".
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
const fs = require('fs'); | |
const rawData = fs.readFileSync('bsconfig.json') | |
var bsconfig = JSON.parse(rawData) | |
var choice = process.argv[1] | |
// There's a chance this code is run like this: 'node <this script>' | |
if (process.argv[0] !== __filename){ | |
choice = process.argv[2] | |
} | |
if (['es6', 'es6-global', 'commonjs'].includes(choice)){ | |
bsconfig['package-specs']['module'] = choice | |
bsconfig_str = JSON.stringify(bsconfig, null, 2) | |
fs.writeFileSync ('bsconfig.json', bsconfig_str) | |
process.exit(0) | |
} | |
console.log('USAGE: node change_bsconfig [type]') | |
console.log('The \'type\'s: es6, es6-global, commonjs') | |
console.log('What you chose was ' + choice) | |
process.exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment