Files
docx-js/scripts/types-absolute-fixer.ts
Dolan Miu 982d923553 Improve import alias
@file/ and @export/ instead of file/ and export/ etc
2022-06-26 23:26:42 +01:00

19 lines
539 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}"`;
},
});
}