1{
2 curl,
3 darwin,
4 lib,
5 netlify-cli,
6 runCommand,
7 stdenv,
8}:
9
10runCommand "netlify-cli-test" {
11 nativeBuildInputs = [
12 netlify-cli
13 curl
14 ] ++ lib.optionals stdenv.isDarwin [
15 darwin.ps
16 ];
17 meta.timeout = 600;
18} ''
19 mkdir home
20 export HOME=$PWD/home
21
22 # Create a simple site
23 echo '<h1>hi</h1>' >index.html
24 echo '/with-redirect /' >_redirects
25
26 # Start a local server and wait for it to respond
27 netlify dev --offline --port 8888 2>&1 | tee log &
28 sleep 0.1 || true
29 for (( i=0; i<300; i++ )); do
30 if grep --ignore-case 'Server now ready' <log; then
31 break
32 else
33 sleep 1
34 fi
35 done
36
37 # Test the local server
38 curl -L http://localhost:8888/with-redirect | grep '<h1>hi</h1>'
39
40 # Success
41 touch $out
42''