astro-icon
Advanced tools
Comparing version 0.8.1 to 0.8.2
@@ -1,2 +0,2 @@ | ||
import { statSync, promises as fs } from "node:fs"; | ||
import * as fs from "node:fs/promises"; | ||
import { fileURLToPath, pathToFileURL } from "node:url"; | ||
@@ -18,7 +18,17 @@ import resolvePackage from "resolve-pkg"; | ||
return async (name: string) => { | ||
const baseUrl = new URL(pathToFileURL(resolvePackage(pkg)) + "/"); | ||
const pkgPath = resolvePackage(pkg); | ||
if (!pkgPath) { | ||
throw new Error( | ||
`[astro-icon] Unable to resolve "${pkgPath}"! Is the package installed?"` | ||
); | ||
} | ||
const baseUrl = new URL(pathToFileURL(pkgPath) + "/"); | ||
const path = fileURLToPath( | ||
new URL(dir ? `${dir}/${name}.svg` : `${name}.svg`, baseUrl) | ||
); | ||
if (!exists(path)) { | ||
try { | ||
const svg = await fs.readFile(path, "utf8"); | ||
return svg; | ||
} catch { | ||
throw new Error( | ||
@@ -28,4 +38,2 @@ `[astro-icon] Unable to load "${path}"! Does the file exist?"` | ||
} | ||
const svg = await fs.readFile(path).then((res) => res.toString()); | ||
return svg; | ||
}; | ||
@@ -53,8 +61,1 @@ } | ||
} | ||
const exists = (path: string): boolean => { | ||
try { | ||
return statSync(path).isFile(); | ||
} catch (e) {} | ||
return false; | ||
}; |
import { SPRITESHEET_NAMESPACE } from "./constants"; | ||
import { Props, Optimize } from "./Props"; | ||
import type { Props, Optimize } from "./Props"; | ||
import getFromService from "./resolver"; | ||
@@ -148,4 +148,5 @@ import { optimize as optimizeSVGNative } from "svgo"; | ||
try { | ||
const files = import.meta.globEager( | ||
"/src/icons/**/*.{js,ts,cjs,mjc,cts,mts}" | ||
const files = import.meta.glob( | ||
"/src/icons/**/*.{js,ts,cjs,mjc,cts,mts}", | ||
{ eager: true } | ||
); | ||
@@ -192,3 +193,6 @@ const keys = Object.fromEntries( | ||
try { | ||
const files = import.meta.globEager("/src/icons/**/*.svg", { as: "raw" }); | ||
const files = import.meta.glob("/src/icons/**/*.svg", { | ||
eager: true, | ||
as: "raw", | ||
}); | ||
@@ -195,0 +199,0 @@ if (!(filepath in files)) { |
{ | ||
"name": "astro-icon", | ||
"version": "0.8.1", | ||
"version": "0.8.2", | ||
"type": "module", | ||
@@ -39,6 +39,5 @@ "exports": { | ||
"dependencies": { | ||
"node-fetch": "^3.1.0", | ||
"resolve-pkg": "^2.0.0", | ||
"svgo": "^2.8.0" | ||
} | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32330
2
14
671
- Removednode-fetch@^3.1.0
- Removeddata-uri-to-buffer@4.0.1(transitive)
- Removedfetch-blob@3.2.0(transitive)
- Removedformdata-polyfill@4.0.10(transitive)
- Removednode-domexception@1.0.0(transitive)
- Removednode-fetch@3.3.2(transitive)
- Removedweb-streams-polyfill@3.3.3(transitive)