Skip to content

Commit 7376234

Browse files
committed
on unix systems, attempt to extract the path to npm via call to which
1 parent 404f70e commit 7376234

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/app/FakeLib/NpmHelper.fs

+12-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,22 @@ module Fake.NpmHelper
33
open Fake
44
open System
55
open System.IO
6+
open System.Diagnostics
67

78
/// Default paths to Npm
89
let private npmFileName =
910
match isUnix with
10-
| true when File.Exists("/usr/bin/npm") -> "/usr/bin/npm"
11-
| true when File.Exists("/usr/local/bin/npm") -> "/usr/local/bin/npm"
11+
| true ->
12+
let info = new ProcessStartInfo("which","npm")
13+
info.RedirectStandardOutput <- true
14+
info.UseShellExecute <- false
15+
info.CreateNoWindow <- true
16+
use proc = Process.Start info
17+
proc.WaitForExit()
18+
match proc.ExitCode with
19+
| 0 when not proc.StandardOutput.EndOfStream ->
20+
proc.StandardOutput.ReadLine()
21+
| _ -> "/usr/bin/npm"
1222
| _ -> "./packages/Npm.js/tools/npm.cmd"
1323

1424
/// Arguments for the Npm install command

0 commit comments

Comments
 (0)