UNPKG

@rushstack/lockfile-explorer

Version:

Rush Lockfile Explorer: The UI for solving version conflicts quickly in a large monorepo

59 lines 1.9 kB
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. import { parentPort, workerData } from 'node:worker_threads'; import * as path from 'node:path'; // debugger; const { pnpmfilePath } = workerData; const resolvedPath = path.resolve(pnpmfilePath); let pnpmfileModule = undefined; let pnpmfileModuleError = undefined; try { pnpmfileModule = require(resolvedPath); } catch (error) { pnpmfileModuleError = error; } // eslint-disable-next-line @rushstack/no-new-null const threadParentPort = parentPort; if (!threadParentPort) { throw new Error('Not running in a worker thread'); } threadParentPort.on('message', async (message) => { const { id, packageJson } = message; if (pnpmfileModuleError) { threadParentPort.postMessage({ kind: 'error', id, error: pnpmfileModuleError.message }); return; } try { if (!pnpmfileModule || !pnpmfileModule.hooks || typeof pnpmfileModule.hooks.readPackage !== 'function') { // No transformation needed threadParentPort.postMessage({ kind: 'return', id, result: packageJson }); return; } const pnpmContext = { log: (logMessage) => threadParentPort.postMessage({ kind: 'log', id, log: logMessage }) }; const result = await pnpmfileModule.hooks.readPackage({ ...packageJson }, pnpmContext); threadParentPort.postMessage({ kind: 'return', id, result }); } catch (e) { threadParentPort.postMessage({ kind: 'error', id, error: e.message }); } }); //# sourceMappingURL=pnpmfileRunnerWorkerThread.js.map