(tracer?: (message: string) => void)
| 177 | } |
| 178 | |
| 179 | export function resolveGlobalNodePath(tracer?: (message: string) => void): string | undefined { |
| 180 | let npmCommand = isWindows() ? 'npm.cmd' : 'npm'; |
| 181 | |
| 182 | let stdout = spawnSync(npmCommand, ['config', 'get', 'prefix'], { |
| 183 | encoding: 'utf8' |
| 184 | }).stdout; |
| 185 | |
| 186 | if (!stdout) { |
| 187 | if (tracer) { |
| 188 | tracer(`'npm config get prefix' didn't return a value.`); |
| 189 | } |
| 190 | return undefined; |
| 191 | } |
| 192 | let prefix = stdout.trim(); |
| 193 | if (tracer) { |
| 194 | tracer(`'npm config get prefix' value is: ${prefix}`); |
| 195 | } |
| 196 | |
| 197 | if (prefix.length > 0) { |
| 198 | if (isWindows()) { |
| 199 | return path.join(prefix, 'node_modules'); |
| 200 | } else { |
| 201 | return path.join(prefix, 'lib', 'node_modules'); |
| 202 | } |
| 203 | } |
| 204 | return undefined; |
| 205 | } |
| 206 | |
| 207 | interface YarnJsonFormat { |
| 208 | type: string; |
no test coverage detected