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/copy_type.ts

57 lines
1.6 KiB

import { readFile, writeFile } from 'fs';
import * as path from 'path';
import { downLoadFile } from './utils';
//修正d.ts中类型定义出现错误的问题,临时修复,因为d.ts并不能完全快速的合并我们的类型修复PR.
// copyFolderRecursiveSync("./@types/", "./node_modules/");
function downloadTypes(downFiles: { moduleName: string; urlPath: string; files: string[]; })
{
let filePath = path.resolve("./node_modules/" + downFiles.moduleName) + "\\";
for (let file of downFiles.files)
{
try
{
downLoadFile(downFiles.urlPath + file, filePath + file);
console.log("成功", file);
}
catch (error)
{
console.log(file, error);
}
}
}
downloadTypes({
moduleName: "jquery",
urlPath: "https://gitee.com/BearCAD/DefinitelyType2/raw/master/jquery/",
files: [
"index.d.ts"
]
});
readFile("node_modules\\dxf-parser\\dist\\ParseHelpers.js", "utf-8", (err, str) =>
{
if (str.includes("case 210:")) return;
str = str.replace("case 330:", `
case 210:
entity.extrusionDirectionX = curr.value;
break;
case 220:
entity.extrusionDirectionY = curr.value;
break;
case 230:
entity.extrusionDirectionZ = curr.value;
break;
case 330:
`);
writeFile("node_modules\\dxf-parser\\dist\\ParseHelpers.js", str, err =>
{
if (err)
console.log("dxf parse写入失败");
else
console.log("dxf parse hack 成功");
});
});