Skip to content

Commit

Permalink
improve default npm path handling
Browse files Browse the repository at this point in the history
  • Loading branch information
krgn committed Jun 20, 2016
1 parent c063bf4 commit f2ccb3a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
17 changes: 9 additions & 8 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
#!/bin/bash
#!/usr/bin/env bash

if test "$OS" = "Windows_NT"
then
# use .Net

.paket/paket.bootstrapper.exe
exit_code=$?
if [ $exit_code -ne 0 ]; then
exit $exit_code
exit $exit_code
fi

.paket/paket.exe restore
exit_code=$?
if [ $exit_code -ne 0 ]; then
exit $exit_code
exit $exit_code
fi

[ ! -e build.fsx ] && .paket/paket.exe update
[ ! -e build.fsx ] && packages/build/FAKE/tools/FAKE.exe init.fsx
packages/build/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx
packages/build/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx
else
# use mono
mono .paket/paket.bootstrapper.exe
exit_code=$?
if [ $exit_code -ne 0 ]; then
exit $exit_code
exit $exit_code
fi

mono .paket/paket.exe restore
exit_code=$?
if [ $exit_code -ne 0 ]; then
exit $exit_code
exit $exit_code
fi

[ ! -e build.fsx ] && mono .paket/paket.exe update
[ ! -e build.fsx ] && mono packages/build/FAKE/tools/FAKE.exe init.fsx
mono packages/build/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx
mono packages/build/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx
fi
14 changes: 13 additions & 1 deletion src/app/FakeLib/NpmHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,23 @@ module Fake.NpmHelper
open Fake
open System
open System.IO
open System.Diagnostics

/// Default paths to Npm
let private npmFileName =
match isUnix with
| true -> "/usr/local/bin/npm"
| true ->
let info = new ProcessStartInfo("which","npm")
info.StandardOutputEncoding <- System.Text.Encoding.UTF8
info.RedirectStandardOutput <- true
info.UseShellExecute <- false
info.CreateNoWindow <- true
use proc = Process.Start info
proc.WaitForExit()
match proc.ExitCode with
| 0 when not proc.StandardOutput.EndOfStream ->
proc.StandardOutput.ReadLine()
| _ -> "/usr/bin/npm"
| _ -> "./packages/Npm.js/tools/npm.cmd"

/// Arguments for the Npm install command
Expand Down

0 comments on commit f2ccb3a

Please sign in to comment.