MCPcopy Index your code
hub / github.com/microsoft/vscode-languageserver-node / resolveGlobalNodePath

Function resolveGlobalNodePath

server/src/files.ts:179–205  ·  view source on GitHub ↗
(tracer?: (message: string) => void)

Source from the content-addressed store, hash-verified

177}
178
179export 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
207interface YarnJsonFormat {
208 type: string;

Callers 1

resolveModulePathFunction · 0.85

Calls 2

isWindowsFunction · 0.85
tracerFunction · 0.85

Tested by

no test coverage detected