async function updatePackageChangelog(packageMetadata, updateSpecification, rootDir = WORKSPACE_ROOT) {
    const { dirPath: projectRootDirectory } = packageMetadata;
    const { newVersion, repositoryUrl } = updateSpecification;
    let changelogContent;
    const packagePath = external_path_default().join(rootDir, projectRootDirectory);
    const changelogPath = external_path_default().join(packagePath, CHANGELOG_FILE_NAME);
    try {
        changelogContent = await external_fs_.promises.readFile(changelogPath, 'utf-8');
    }
    catch (error) {
        console.error(`Failed to read changelog in "${projectRootDirectory}".`);
        throw error;
    }
    const newChangelogContent = await (0,auto_changelog_dist.updateChangelog)({
        changelogContent,
        currentVersion: newVersion,
        isReleaseCandidate: true,
        projectRootDirectory,
        repoUrl: repositoryUrl,
    });
    if (!newChangelogContent) {
        const packageName = packageMetadata.manifest.name;
        throw new Error(`"updateChangelog" returned an empty value for package ${packageName ? `"${packageName}"` : `at "${packagePath}"`}.`);
    }
    await external_fs_.promises.writeFile(changelogPath, newChangelogContent);
}
/**
 * Updates the changelog file of the given package, using
 * @metamask/auto-changelog. Assumes that the changelog file is located at the
 * package root directory and named "CHANGELOG.md".
 *
 * @param packageMetadata - The metadata of the package to update.
 * @param updateSpecification - The update specification, which determines how
 * the update is performed.
 */
Updates the changelog file of the given package, using
@metamask/auto-changelog. Assumes that the changelog file is located at the
package root directory and named "CHANGELOG.md".

@param packageMetadata - The metadata of the package to update.
@param updateSpecification - The update specification, which determines how
the update is performed.
Updates the changelog file of the given package using @metamask / auto - changelog . Assumes that the changelog file is located at the package root directory and named " CHANGELOG . md " . @param packageMetadata - The metadata of the package to update . @param updateSpecification - The update specification which determines how the update is performed .
async function updatePackageChangelog(packageMetadata, updateSpecification, rootDir = WORKSPACE_ROOT) {
    const { dirPath: projectRootDirectory } = packageMetadata;
    const { newVersion, repositoryUrl } = updateSpecification;
    let changelogContent;
    const packagePath = external_path_default().join(rootDir, projectRootDirectory);
    const changelogPath = external_path_default().join(packagePath, CHANGELOG_FILE_NAME);
    try {
        changelogContent = await external_fs_.promises.readFile(changelogPath, 'utf-8');
    }
    catch (error) {
        console.error(`Failed to read changelog in "${projectRootDirectory}".`);
        throw error;
    }
    const newChangelogContent = await (0,auto_changelog_dist.updateChangelog)({
        changelogContent,
        currentVersion: newVersion,
        isReleaseCandidate: true,
        projectRootDirectory,
        repoUrl: repositoryUrl,
    });
    if (!newChangelogContent) {
        const packageName = packageMetadata.manifest.name;
        throw new Error(`"updateChangelog" returned an empty value for package ${packageName ? `"${packageName}"` : `at "${packagePath}"`}.`);
    }
    await external_fs_.promises.writeFile(changelogPath, newChangelogContent);
}
async function updatePackageChangelog ( packageMetadata , updateSpecification , rootDir = WORKSPACE_ROOT ) { const { dirPath : projectRootDirectory } = packageMetadata ; const { newVersion , repositoryUrl } = updateSpecification ; let changelogContent ; const packagePath = external_path_default ( ) . join ( rootDir , projectRootDirectory ) ; const changelogPath = external_path_default ( ) . join ( packagePath , CHANGELOG_FILE_NAME ) ; try { changelogContent = await external_fs_ . promises . readFile ( changelogPath , 'utf-8' ) ; } catch ( error ) { console . error ( ` ${ projectRootDirectory } ` ) ; throw error ; } const newChangelogContent = await ( 0 , auto_changelog_dist . updateChangelog ) ( { changelogContent , currentVersion : newVersion , isReleaseCandidate : true , projectRootDirectory , repoUrl : repositoryUrl , } ) ; if ( ! newChangelogContent ) { const packageName = packageMetadata . manifest . name ; throw new Error ( ` ${ packageName ? ` ${ packageName } ` : ` ${ packagePath } ` } ` ) ; } await external_fs_ . promises . writeFile ( changelogPath , newChangelogContent ) ; }
Updates the changelog file of the given package, using
 @metamask/auto-changelog.
Updates the changelog file of the given package using @metamask / auto - changelog .