Files
pnpm/packages/plugin-commands-installation/src/nodeExecPath.ts
2021-10-16 23:33:34 +03:00

15 lines
443 B
TypeScript

import { promises as fs } from 'fs'
import which from '@zkochan/which'
export default async function () {
try {
// The system default Node.js executable is prefered
// not the one used to run the pnpm CLI.
const nodeExecPath = await which('node')
return fs.realpath(nodeExecPath)
} catch (err: any) { // eslint-disable-line
if (err['code'] !== 'ENOENT') throw err
return process.env.NODE ?? process.execPath
}
}