Skip to content

Commit f2ccb3a

Browse files
committed
improve default npm path handling
1 parent c063bf4 commit f2ccb3a

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

build.sh

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,39 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
2+
23
if test "$OS" = "Windows_NT"
34
then
45
# use .Net
56

67
.paket/paket.bootstrapper.exe
78
exit_code=$?
89
if [ $exit_code -ne 0 ]; then
9-
exit $exit_code
10+
exit $exit_code
1011
fi
1112

1213
.paket/paket.exe restore
1314
exit_code=$?
1415
if [ $exit_code -ne 0 ]; then
15-
exit $exit_code
16+
exit $exit_code
1617
fi
17-
18+
1819
[ ! -e build.fsx ] && .paket/paket.exe update
1920
[ ! -e build.fsx ] && packages/build/FAKE/tools/FAKE.exe init.fsx
20-
packages/build/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx
21+
packages/build/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx
2122
else
2223
# use mono
2324
mono .paket/paket.bootstrapper.exe
2425
exit_code=$?
2526
if [ $exit_code -ne 0 ]; then
26-
exit $exit_code
27+
exit $exit_code
2728
fi
2829

2930
mono .paket/paket.exe restore
3031
exit_code=$?
3132
if [ $exit_code -ne 0 ]; then
32-
exit $exit_code
33+
exit $exit_code
3334
fi
3435

3536
[ ! -e build.fsx ] && mono .paket/paket.exe update
3637
[ ! -e build.fsx ] && mono packages/build/FAKE/tools/FAKE.exe init.fsx
37-
mono packages/build/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx
38+
mono packages/build/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx
3839
fi

src/app/FakeLib/NpmHelper.fs

+13-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,23 @@ 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 -> "/usr/local/bin/npm"
11+
| true ->
12+
let info = new ProcessStartInfo("which","npm")
13+
info.StandardOutputEncoding <- System.Text.Encoding.UTF8
14+
info.RedirectStandardOutput <- true
15+
info.UseShellExecute <- false
16+
info.CreateNoWindow <- true
17+
use proc = Process.Start info
18+
proc.WaitForExit()
19+
match proc.ExitCode with
20+
| 0 when not proc.StandardOutput.EndOfStream ->
21+
proc.StandardOutput.ReadLine()
22+
| _ -> "/usr/bin/npm"
1123
| _ -> "./packages/Npm.js/tools/npm.cmd"
1224

1325
/// Arguments for the Npm install command

0 commit comments

Comments
 (0)