Files
docx-js/scripts/types-absolute-fixer.ts

21 lines
544 B
TypeScript
Raw Normal View History

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