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

21 lines
543 B
JavaScript
Raw Normal View History

2018-02-02 01:56:08 +00:00
const glob = require("glob");
const replace = require("replace-in-file");
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("");
return `"${backLevels}${matchSlug}"`;
},
});
}