ethers.js/testcases/test-env/test-tsc/prepare.cjs
2023-04-28 20:11:35 +09:00

20 lines
582 B
JavaScript

const fs = require("fs");
function replace(filename, key, value) {
const data = fs.readFileSync(filename).toString();
data = data.replace(key, value);
fs.writeFileSync(filename, data);
}
// moduleResolution: node, node16, nodenext
replace("tsconfig.json", "${TS_MODULE_RESOLUTION}", process.argv[2]);
// module: commonjs, es2020
replace("tsconfig.json", "${TS_MODULE}", process.argv[3]);
// type: module, commonjs
replace("package.json", "${PKG_TYPE}", process.argv[4]);
// JavaScript
fs.writeFileSync("index.js", fs.readFileSync("js-" + process.argv[4] + ".js"));