mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-24 18:11:39 -04:00
15 lines
385 B
TypeScript
15 lines
385 B
TypeScript
import fs = require('mz/fs')
|
|
import path = require('path')
|
|
|
|
export default async function realNodeModulesDir (prefix: string): Promise<string> {
|
|
const dirName = path.join(prefix, 'node_modules')
|
|
try {
|
|
return await fs.realpath(dirName)
|
|
} catch (err) {
|
|
if (err['code'] === 'ENOENT') { // tslint:disable-line:no-string-literal
|
|
return dirName
|
|
}
|
|
throw err
|
|
}
|
|
}
|