Creates a new NodeJS app
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "simple-node-app",
|
||||
"version": "1.0.0",
|
||||
"description": "A simple Node.js app for GitHub Actions PR testing",
|
||||
"main": "src/app.js",
|
||||
"scripts": {
|
||||
"test": "bash src/test.sh"
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function greet(name) {
|
||||
|
||||
return `Hello, ${name}!`;
|
||||
|
||||
}
|
||||
|
||||
module.export = greet;
|
||||
|
||||
if (require.main === module){
|
||||
console.log(greet("World"))
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
#src/test.sj
|
||||
EXPECTED=$"Hello, Test!"
|
||||
|
||||
OUTPUT=${node -e "console.log(require('./src/app'))('Test)"}
|
||||
|
||||
if [ "$OUTPUT" == $"$EXPECTED" ]; then
|
||||
|
||||
echo "Test passed!"
|
||||
|
||||
exit 0
|
||||
|
||||
else
|
||||
|
||||
echo "Test failed! Expected '$EXPECTED' but got '$OUTPUT'"
|
||||
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user