Add back types absolute fixer

This commit is contained in:
Dolan Miu
2021-09-28 19:56:29 +01:00
parent 1f078e0687
commit 536204e5ef
4 changed files with 7 additions and 9 deletions

View File

@ -1,18 +1,16 @@
import * as glob from "glob";
import * as replace from "replace-in-file";
import { replaceInFile } from "replace-in-file";
const files = glob.sync("build/**/*.d.ts");
for (const file of files) {
replace({
replaceInFile({
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("");
const backLevels = Array(levelCount).fill("../").join("");
return `"${backLevels}${matchSlug}"`;
},