|
| 1 | +/* |
| 2 | + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. |
| 3 | + Copyright (C) 2023 Spacebar and Spacebar Contributors |
| 4 | + |
| 5 | + This program is free software: you can redistribute it and/or modify |
| 6 | + it under the terms of the GNU Affero General Public License as published |
| 7 | + by the Free Software Foundation, either version 3 of the License, or |
| 8 | + (at your option) any later version. |
| 9 | + |
| 10 | + This program is distributed in the hope that it will be useful, |
| 11 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + GNU Affero General Public License for more details. |
| 14 | + |
| 15 | + You should have received a copy of the GNU Affero General Public License |
| 16 | + along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 17 | +*/ |
| 18 | + |
| 19 | +/* |
| 20 | + Super simple script to check if the server starts at all, for use in gh actions. |
| 21 | + Not a proper test framework by any means. |
| 22 | +*/ |
| 23 | + |
| 24 | +const { spawn } = require("child_process"); |
| 25 | +const path = require("path"); |
| 26 | + |
| 27 | +const server = spawn("node", [ |
| 28 | + path.join(__dirname, "..", "dist", "bundle", "start.js"), |
| 29 | +]); |
| 30 | + |
| 31 | +server.stdout.on("data", (data) => { |
| 32 | + process.stdout.write(data); |
| 33 | + |
| 34 | + if (data.toString().toLowerCase().includes("listening")) { |
| 35 | + // we good :) |
| 36 | + console.log("we good"); |
| 37 | + process.exit(); |
| 38 | + } |
| 39 | +}); |
| 40 | + |
| 41 | +server.stderr.on("data", (err) => { |
| 42 | + process.stdout.write(err); |
| 43 | + // we bad :( |
| 44 | + process.kill(1); |
| 45 | +}); |
| 46 | + |
| 47 | +server.on("close", (code) => { |
| 48 | + console.log("closed with code", code); |
| 49 | + process.exit(code); |
| 50 | +}); |
0 commit comments