-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode_test.sh
More file actions
48 lines (40 loc) · 1.07 KB
/
node_test.sh
File metadata and controls
48 lines (40 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
#
# Script to test node.js runtime
echo "=============== Node.js =============="
echo "[*] Creating myapp directory..."
echo
# Create directory and cd to it
mkdir myapp
cd myapp
# Create the package.json file
echo "[*] Creating package.json file..."
echo
echo '{
"name": "myapp",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}' > package.json
# Install Express silently
echo "[*] Installing Express..."
echo
npm install express --save > "/dev/null" 2>&1
# Create a sample app.js file
echo "[*] Creating test app.js file..."
echo
echo "const express = require('express')" >> app.js
echo "const app = express()" >> app.js
echo "app.get('/', (req, res) => res.send('Hello World!'))" >> app.js
echo "app.listen(3000, () => console.log('Hello World! Example app listening on port 3000!'))" >> app.js
# Run app.js in the background, sleep to manke sure we get an output to the console
echo "[*] Running app.js..."
echo
node app.js &
sleep 3
echo