(pkg: string)
| 101 | fs.mkdirSync(path.dirname(filePath), { recursive: true }); |
| 102 | const data = await fetchToBuffer(url); |
| 103 | if (fs.existsSync(filePath)) { |
| 104 | const old = fs.readFileSync(filePath); |
| 105 | if (old.length === data.length && old.equals(data)) return; |
| 106 | } |
| 107 | fs.writeFileSync(filePath, data); |
| 108 | } |
| 109 | |
| 110 | function requireOrInstall(pkg: string): any { |
| 111 | try { |
| 112 | return require(pkg); |
| 113 | } catch (err: any) { |
| 114 | const code = err?.code; |
| 115 | if (code !== "MODULE_NOT_FOUND" && code !== "ERR_MODULE_NOT_FOUND") throw err; |
| 116 | console.warn("quote loader installing npm package", { pkg }); |
no test coverage detected