You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
WebCAD/utils/replace_api_file.ts

49 lines
1.5 KiB

import * as fs from "fs-extra-plus";
import * as path from "path";
function replace_api_file(filePath: string): Promise<void>
{
return new Promise((res, rej) =>
{
fs.readFile(filePath, "utf8", (err, data) =>
{
if (err)
{
console.log(err);
res();
return;
}
data = data.replace("require(\"../GLSL/GoodchSimple.vs\")", "\"\"");
data = data.replace("require(\"../GLSL/GoodchSimple2.fs\")", "\"\"");
data = data.replace("require(\"./GoodchSimple.vs\")", "\"\"");
data = data.replace("require(\"./GoodchSimple.fs\")", "\"\"");
data = data.replace("import { iaop } from 'xaop';", "");
data = data.replace("import { observable, toJS } from 'mobx';", "function observable() { };\r\nfunction toJS() { };");
fs.writeFile(filePath, data, err =>
{
if (err)
console.error(filePath + "操作失败!");
res();
});
});
});
}
async function main()
{
await replace_api_file(path.resolve(__dirname, "../ue4_api/api.cjs.js"));
await replace_api_file(path.resolve(__dirname, "../ue4_api/api.esm.js"));
await replace_api_file(path.resolve(__dirname, "../api/api.cjs.js"));
await replace_api_file(path.resolve(__dirname, "../api/api.esm.js"));
fs.copy(path.resolve(__dirname, "../ue4_api"), path.resolve(__dirname, "../../webcad_ue4_api"));
}
main();