Skip to content

Instantly share code, notes, and snippets.

@painedpineapple
Last active January 11, 2021 23:14
Show Gist options
  • Save painedpineapple/e3d0d90ade755bb8b5c0df97b76a2819 to your computer and use it in GitHub Desktop.
Save painedpineapple/e3d0d90ade755bb8b5c0df97b76a2819 to your computer and use it in GitHub Desktop.
Convert all Reason files in a project to ReScript
/**
* 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