From a9e92428032bdc8b00993088603e8149cded910e Mon Sep 17 00:00:00 2001 From: simplymichael Date: Sun, 1 Sep 2024 17:49:01 +0100 Subject: [PATCH] refactor: :hammer: delete the bin/directory; move the bob definition into the root bob file --- bin/bob | 10 ---------- bin/start-server.js | 29 ----------------------------- bob | 9 ++++----- 3 files changed, 4 insertions(+), 44 deletions(-) delete mode 100644 bin/bob delete mode 100644 bin/start-server.js diff --git a/bin/bob b/bin/bob deleted file mode 100644 index 854e69a..0000000 --- a/bin/bob +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env node - -"use strict"; - -const path = require("node:path"); - -require(`${path.dirname(__dirname).replace(/\\/g, "/")}/src/bootstrap/app`) - .dispatch(process.argv.slice(2)) - .then((status) => status !== undefined && process.exit(status)) - .catch((err) => process.exit(err.code)); diff --git a/bin/start-server.js b/bin/start-server.js deleted file mode 100644 index 8701600..0000000 --- a/bin/start-server.js +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env node - -const cp = require("node:child_process"); -const path = require("node:path"); -const { parseArgs } = require("node:util"); - -const rootDir = path.dirname(__dirname); -const options = parseArgs({ - allowPositionals: true, - options: { - port: { type: "string", short: "p" }, - }, -}); - -function startServer() { - let command = `node ${rootDir}${path.sep}bin${path.sep}bob serve`; - const port = options.values.port; - - if(port) { - command += ` --port ${port}`; - } - - return new Promise((resolve, reject) => { - cp.spawn(command, { stdio: "inherit", shell: true }) - .on("close", (code) => (code === 0) ? resolve(code) : reject(code)); - }); -} - -startServer(); diff --git a/bob b/bob index 45b502a..aa4581e 100644 --- a/bob +++ b/bob @@ -4,8 +4,7 @@ const path = require("node:path"); -/* - * Support `node bob ...` commands - */ - -require(`${__dirname.replace(/\\/g, "/")}/bin/bob`); +require(`${__dirname.replace(/\\/g, "/")}/src/bootstrap/app`) + .dispatch(process.argv.slice(2)) + .then((status) => status !== undefined && process.exit(status)) + .catch((err) => process.exit(err.code));