Skip to content

Commit cc70088

Browse files
committed
Auto-install httpserver npm module
1 parent 5dad2a5 commit cc70088

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

docs/README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
# Intro
2-
Documentation for JsonApiDotNetCore is produced using [DocFX](https://dotnet.github.io/docfx/) from several files in this directory.
2+
Documentation for JsonApiDotNetCore is produced using [docfx](https://dotnet.github.io/docfx/) from several files in this directory.
33
In addition, the example request/response pairs are generated by executing `curl` commands against the GettingStarted project.
44

55
# Installation
6-
Run the following command once to setup your system:
7-
8-
```
9-
npm install -g httpserver
10-
```
6+
You need to have 'npm' installed. Download Node.js from https://nodejs.org/.
117

128
# Running
139
The next command regenerates the documentation website and opens it in your default browser:

docs/build-dev.ps1

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#Requires -Version 7.0
22

33
# This script builds the documentation website, starts a web server and opens the site in your browser. Intended for local development.
4-
# It is assumed that you have already installed httpserver.
5-
# If that's not the case, run the next command:
6-
# npm install -g httpserver
74

85
param(
96
# Specify -NoBuild to skip code build and examples generation. This runs faster, so handy when only editing Markdown files.
@@ -16,6 +13,21 @@ function VerifySuccessExitCode {
1613
}
1714
}
1815

16+
function EnsureHttpServerIsInstalled {
17+
if ((Get-Command "npm" -ErrorAction SilentlyContinue) -eq $null) {
18+
throw "Unable to find npm in your PATH. please install Node.js first."
19+
}
20+
21+
npm list --depth 1 --global httpserver >$null
22+
23+
if ($LastExitCode -eq 1) {
24+
npm install -g httpserver
25+
}
26+
}
27+
28+
EnsureHttpServerIsInstalled
29+
VerifySuccessExitCode
30+
1931
if (-Not $NoBuild -Or -Not (Test-Path -Path _site)) {
2032
Remove-Item _site -Recurse -ErrorAction Ignore
2133

0 commit comments

Comments
 (0)