Skip to content

Commit d65949a

Browse files
fixup: add exists to DeserializedPackageConfig
1 parent eed739c commit d65949a

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/internal/modules/package_json_reader.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ function deserializePackageJSON(path, contents) {
4040
__proto__: null,
4141
type: 'none', // Ignore unknown types for forwards compatibility
4242
},
43+
exists: false,
4344
path,
4445
};
4546
}
@@ -78,6 +79,7 @@ function deserializePackageJSON(path, contents) {
7879
},
7980
}),
8081
},
82+
exists: true,
8183
path: pjsonPath,
8284
};
8385
}
@@ -112,7 +114,7 @@ function read(jsonPath, { base, specifier, isESM } = kEmptyObject) {
112114
return {
113115
__proto__: null,
114116
...result.data,
115-
exists: result.data !== 'none',
117+
exists: result.exists,
116118
pjsonPath: result.path,
117119
};
118120
}
@@ -164,6 +166,7 @@ function getNearestParentPackageJSON(startLocation, everything = false) {
164166
__proto__: null,
165167
...JSONParse(result?.[0]),
166168
},
169+
exists: true,
167170
path: result?.[1],
168171
};
169172
}
@@ -189,10 +192,12 @@ function getPackageScopeConfig(resolved) {
189192
const result = modulesBinding.getPackageScopeConfig(`${resolved}`);
190193

191194
if (ArrayIsArray(result)) {
192-
const { data, path } = deserializePackageJSON(`${resolved}`, result);
195+
const { data, exists, path } = deserializePackageJSON(`${resolved}`, result);
196+
193197
return {
194198
__proto__: null,
195199
...data,
200+
exists,
196201
pjsonPath: path,
197202
};
198203
}

typings/internalBinding/modules.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ export type FullPackageConfig = RecognizedPackageConfig & {
1010
[key: string]: unknown,
1111
}
1212
export type DeserializedPackageConfig<everything = false> = {
13-
data: everything extends true ? FullPackageConfig : RecognizedPackageConfig
13+
data: everything extends true ? FullPackageConfig : RecognizedPackageConfig,
14+
exists: boolean,
1415
path: URL['pathname'],
1516
}
1617
export type SerializedPackageConfig = [

0 commit comments

Comments
 (0)