import { copyFile, mkdir, rm, symlink } from 'node:fs/promises';
import { dirname, relative } from 'node:path';
import { resolveInstalledFirstPartyComponentPaths } from './resolveInstalledComponentPaths.js';
export async function syncInstalledFirstPartyShims(params) {
    const paths = resolveInstalledFirstPartyComponentPaths({
        componentId: params.componentId,
        channel: params.channel,
        releaseRing: params.releaseRing,
        processEnv: params.processEnv,
    });
    await Promise.all(paths.shimPaths.map(async (shimPath) => {
        await mkdir(dirname(shimPath), { recursive: true });
        await rm(shimPath, { force: true, recursive: true });
        if (process.platform === 'win32') {
            await copyFile(paths.binaryPath, shimPath);
            return;
        }
        await symlink(relative(dirname(shimPath), paths.binaryPath), shimPath);
    }));
    return {
        shimPaths: paths.shimPaths,
    };
}
//# sourceMappingURL=syncInstalledFirstPartyShims.js.map