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