Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 2x 2x 2x 4x 4x 4x 4x 4x 2x 6x 6x 6x 6x 2x | import { relative, sep } from "path";
import { pathToPosix } from "shared/lib/helpers/path";
const extractPluginPath = (relativePath: string, assetFolder: string) => {
Iif (!relativePath.startsWith("plugins")) {
return undefined;
}
const assetFolderIndex = relativePath.lastIndexOf(assetFolder);
Iif (assetFolderIndex === -1) {
return undefined;
}
const extractedPath = relativePath.substring(
"plugins".length + 1,
assetFolderIndex - 1,
);
return extractedPath.split(sep).join("/");
};
const parseAssetPath = (
filename: string,
projectRoot: string,
assetFolder: string,
) => {
const relativePath = relative(projectRoot, filename);
const plugin = relativePath.startsWith("plugins")
? extractPluginPath(relativePath, assetFolder)
: undefined;
const file = pathToPosix(
plugin
? relative(`plugins/${plugin}/${assetFolder}/`, relativePath)
: relative(`assets/${assetFolder}/`, relativePath),
);
return {
relativePath,
plugin,
file,
};
};
export default parseAssetPath;
|