XpmPackage.readPackageDotJson() method
Reads and parses package.json from the package folder.
Signature
readPackageDotJson({ withThrow, }?: {
withThrow?: boolean;
}): Promise<JsonXpmPackage | undefined>;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
{ withThrow, } |
{ withThrow?: boolean; } |
(Optional) |
Returns
Promise<JsonXpmPackage | undefined>
The parsed package.json content, or undefined when missing or invalid and withThrow is false.
Exceptions
XpmInputError If package.json is missing or invalid and withThrow is true.
Remarks
This method provides flexible error handling for scenarios where a missing or invalid package.json may be expected (e.g., checking whether a folder is a package) versus scenarios where it indicates a critical error (e.g., operating on a known package).
When withThrow is false, the method returns undefined for missing or invalid files, allowing callers to handle the absence gracefully. When withThrow is true, errors are thrown as XpmInputError for consistent error handling across the application.
Generated via tsdoc2docusaurus 1.3.0-pre by API Extractor/Documenter 7.55.2.