1 | import { resolve } from "path"
|
2 | import { hrefToPathname, pathnameToRelativePath } from "@jsenv/href"
|
3 | import {
|
4 | pathnameToOperatingSystemPath,
|
5 | operatingSystemPathToPathname,
|
6 | } from "@jsenv/operating-system-path"
|
7 |
|
8 | let jsenvBundlingProjectPath
|
9 | if (typeof __filename === "string") {
|
10 | jsenvBundlingProjectPath = resolve(__filename, "../../../")
|
11 | } else {
|
12 | const selfPathname = hrefToPathname(import.meta.url)
|
13 | const selfPath = pathnameToOperatingSystemPath(selfPathname)
|
14 | jsenvBundlingProjectPath = resolve(selfPath, "../../")
|
15 | }
|
16 |
|
17 | export { jsenvBundlingProjectPath }
|
18 |
|
19 | export const jsenvBundlingProjectPathname = operatingSystemPathToPathname(jsenvBundlingProjectPath)
|
20 |
|
21 | export const jsenvBundlingRelativePathInception = ({
|
22 | jsenvBundlingRelativePath,
|
23 | projectPathname,
|
24 | }) => {
|
25 | const jsenvPathname = `${jsenvBundlingProjectPathname}${jsenvBundlingRelativePath}`
|
26 | const relativePath = pathnameToRelativePath(jsenvPathname, projectPathname)
|
27 | return relativePath
|
28 | }
|