1 | import { fileRead } from "@dmail/helper"
|
2 | import { pathnameToOperatingSystemPath } from "@jsenv/operating-system-path"
|
3 |
|
4 | export const readProjectImportMap = async ({ projectPathname, importMapRelativePath }) => {
|
5 | if (!importMapRelativePath) return {}
|
6 |
|
7 | try {
|
8 | const importMapString = await fileRead(
|
9 | pathnameToOperatingSystemPath(`${projectPathname}/${importMapRelativePath}`),
|
10 | )
|
11 | return JSON.parse(importMapString)
|
12 | } catch (e) {
|
13 | if (e && e.code === "ENOENT") {
|
14 | return {}
|
15 | }
|
16 | throw e
|
17 | }
|
18 | }
|