2019-01-15 00:23:01 +00:00
|
|
|
import * as glob from "glob";
|
2021-09-28 19:56:29 +01:00
|
|
|
import { replaceInFile } from "replace-in-file";
|
2018-02-02 01:56:08 +00:00
|
|
|
|
|
|
|
const files = glob.sync("build/**/*.d.ts");
|
|
|
|
|
|
|
|
for (const file of files) {
|
2021-09-28 19:56:29 +01:00
|
|
|
replaceInFile({
|
2018-02-02 01:56:08 +00:00
|
|
|
files: file,
|
2022-06-26 23:26:42 +01:00
|
|
|
from: /"@[a-z/-]*"/gi,
|
2018-02-02 01:56:08 +00:00
|
|
|
to: (match) => {
|
2022-06-26 23:26:42 +01:00
|
|
|
const matchSlug = match.replace(/['"]+/g, "").replace(/[@]+/g, "").trim();
|
2023-03-18 23:16:41 +00:00
|
|
|
const levelCount = file.split(/[\/\\]/).length - 2;
|
2021-09-28 19:56:29 +01:00
|
|
|
const backLevels = Array(levelCount).fill("../").join("");
|
2018-02-02 01:56:08 +00:00
|
|
|
|
2019-01-15 00:23:01 +00:00
|
|
|
return `"${backLevels}${matchSlug}"`;
|
2018-02-02 01:56:08 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|