@nsnanocat/util 2.5.14 → 2.5.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/polyfill/Storage.js +6 -4
package/package.json
CHANGED
package/polyfill/Storage.js
CHANGED
|
@@ -288,8 +288,10 @@ export class Storage {
|
|
|
288
288
|
if ($app !== "Node.js") return {};
|
|
289
289
|
// 优先复用全局运行时对象,不存在时再按需加载。
|
|
290
290
|
// Prefer reusing global runtime modules and lazily require when missing.
|
|
291
|
-
|
|
292
|
-
if (!globalThis.
|
|
291
|
+
// eslint-disable-next-line n/no-missing-require, n/prefer-node-protocol
|
|
292
|
+
if (!globalThis.fs) globalThis.fs = require("fs");
|
|
293
|
+
// eslint-disable-next-line n/no-missing-require, n/prefer-node-protocol
|
|
294
|
+
if (!globalThis.path) globalThis.path = require("path");
|
|
293
295
|
const dataFilePathCandidates = [...new Set([globalThis.path.resolve(dataFile), globalThis.path.resolve(process.cwd(), dataFile)])];
|
|
294
296
|
const dataFilePath = dataFilePathCandidates.find(filePath => globalThis.fs.existsSync(filePath));
|
|
295
297
|
if (!dataFilePath) return {};
|
|
@@ -313,8 +315,8 @@ export class Storage {
|
|
|
313
315
|
if ($app !== "Node.js") return;
|
|
314
316
|
// 优先复用全局运行时对象,不存在时再按需加载。
|
|
315
317
|
// Prefer reusing global runtime modules and lazily require when missing.
|
|
316
|
-
if (!globalThis.fs) globalThis.fs = require("
|
|
317
|
-
if (!globalThis.path) globalThis.path = require("
|
|
318
|
+
if (!globalThis.fs) globalThis.fs = require("fs");
|
|
319
|
+
if (!globalThis.path) globalThis.path = require("path");
|
|
318
320
|
const dataFilePathCandidates = [...new Set([globalThis.path.resolve(dataFile), globalThis.path.resolve(process.cwd(), dataFile)])];
|
|
319
321
|
const dataFilePath = dataFilePathCandidates.find(filePath => globalThis.fs.existsSync(filePath)) ?? dataFilePathCandidates[0];
|
|
320
322
|
const jsonData = JSON.stringify(this.data);
|