MCPcopy Index your code
hub / github.com/nodejs/node / readPackageJsonField

Function readPackageJsonField

test/fixtures/snapshot/typescript.js:42392–42408  ·  view source on GitHub ↗
(jsonContent, fieldName, typeOfTag, state)

Source from the content-addressed store, hash-verified

42390 };
42391 }
42392 function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
42393 if (!ts.hasProperty(jsonContent, fieldName)) {
42394 if (state.traceEnabled) {
42395 trace(state.host, ts.Diagnostics.package_json_does_not_have_a_0_field, fieldName);
42396 }
42397 return;
42398 }
42399 var value = jsonContent[fieldName];
42400 if (typeof value !== typeOfTag || value === null) { // eslint-disable-line no-null/no-null
42401 if (state.traceEnabled) {
42402 // eslint-disable-next-line no-null/no-null
42403 trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, fieldName, typeOfTag, value === null ? "null" : typeof value);
42404 }
42405 return;
42406 }
42407 return value;
42408 }
42409 function readPackageJsonPathField(jsonContent, fieldName, baseDirectory, state) {
42410 var fileName = readPackageJsonField(jsonContent, fieldName, "string", state);
42411 if (fileName === undefined) {

Callers 2

readPackageJsonPathFieldFunction · 0.85

Calls 1

traceFunction · 0.85

Tested by

no test coverage detected