ethers.js/testcases/test-env/test-tsc/prepare.cjs

21 lines
628 B
JavaScript
Raw Permalink Normal View History

2023-04-28 20:11:35 +09:00
const fs = require("fs");
function replace(filename, key, value) {
2023-04-28 20:14:46 +09:00
let data = fs.readFileSync(filename).toString();
2023-04-28 20:11:35 +09:00
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]);
2023-04-28 21:10:09 +09:00
// type: commonjs, module
const type = (process.argv[3] === "commonjs") ? "commonjs": "module";
replace("package.json", "${PKG_TYPE}", type);
2023-04-28 20:11:35 +09:00
// JavaScript
2023-04-28 21:10:09 +09:00
fs.writeFileSync("index.ts", fs.readFileSync("js-" + type + ".ts"));