Files
docx-js/scripts/types-absolute-fixer.ts
Dolan Miu b600fd9324 Add fix to allow for different types of slash to be supported
Maybe updating glob broke it for Windows
2023-03-18 23:16:41 +00:00

19 lines
544 B
TypeScript

import * as glob from "glob";
import { replaceInFile } from "replace-in-file";
const files = glob.sync("build/**/*.d.ts");
for (const file of files) {
replaceInFile({
files: file,
from: /"@[a-z/-]*"/gi,
to: (match) => {
const matchSlug = match.replace(/['"]+/g, "").replace(/[@]+/g, "").trim();
const levelCount = file.split(/[\/\\]/).length - 2;
const backLevels = Array(levelCount).fill("../").join("");
return `"${backLevels}${matchSlug}"`;
},
});
}