1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- 'use strict';
- const { SafeMap } = require('./node-primordials');
- const { internalModuleReadJSON } = require('./node-internal-fs');
- const { pathToFileURL } = require('url');
- const { toNamespacedPath } = require('path');
- const cache = new SafeMap();
- let manifest;
- function read(jsonPath) {
- if (cache.has(jsonPath)) {
- return cache.get(jsonPath);
- }
- const [string, containsKeys] = internalModuleReadJSON(
- toNamespacedPath(jsonPath)
- );
- const result = { string, containsKeys };
- const { getOptionValue } = require('./node-options');
- if (string !== undefined) {
- if (manifest === undefined) {
-
-
-
-
- manifest = null;
- }
- if (manifest !== null) {
- const jsonURL = pathToFileURL(jsonPath);
- manifest.assertIntegrity(jsonURL, string);
- }
- }
- cache.set(jsonPath, result);
- return result;
- }
- module.exports = { read };
|