Last active
January 11, 2021 23:14
-
-
Save painedpineapple/e3d0d90ade755bb8b5c0df97b76a2819 to your computer and use it in GitHub Desktop.
Convert all Reason files in a project to ReScript
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
/** | |
* 1. Make sure "glob" is installed globally | |
* 2. Update src path if necessary | |
* 3. Run `node res_of_re.js` | |
*/ | |
let glob = require("glob"); | |
let { exec } = require("child_process"); | |
glob("src/**/*.re", (err, files) => { | |
if (err) { | |
return console.log("There was a problem reading the directory", err); | |
} | |
files.map((file) => { | |
let parts = file.split(".re"); | |
let path = parts[0]; | |
exec( | |
`node_modules/.bin/bsc -format ${path}.re > ${path}.res`, | |
(err, stdout, stderr) => { | |
if (err) { | |
console.error( | |
`❌ ${path}`, | |
err | |
); | |
} else { | |
exec(`rm ${path}.re`, (err, stdout, stderr) => { | |
if (err) { | |
console.error( | |
`❌ ${path}`, | |
err | |
); | |
} else { | |
console.log(`✅ ${path}`); | |
} | |
}); | |
} | |
} | |
); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment