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