From ead9bdc9fc1e9cc62a26e59f6880a13aa864f931 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 6 May 2021 14:56:18 -0300 Subject: break up utility file, get build for sure working still Much Work Yet Ahead but this is good progress!! also the site is in a working state afaict and thats a kinda nice milestone lmbo --- src/util/node-utils.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/util/node-utils.js (limited to 'src/util/node-utils.js') diff --git a/src/util/node-utils.js b/src/util/node-utils.js new file mode 100644 index 0000000..d660612 --- /dev/null +++ b/src/util/node-utils.js @@ -0,0 +1,27 @@ +// Utility functions which are only relevant to particular Node.js constructs. + +// Very cool function origin8ting in... http-music pro8a8ly! +// Sorry if we happen to 8e violating past-us's copyright, lmao. +export function promisifyProcess(proc, showLogging = true) { + // Takes a process (from the child_process module) and returns a promise + // that resolves when the process exits (or rejects, if the exit code is + // non-zero). + // + // Ayy look, no alpha8etical second letter! Couldn't tell this was written + // like three years ago 8efore I was me. 8888) + + return new Promise((resolve, reject) => { + if (showLogging) { + proc.stdout.pipe(process.stdout); + proc.stderr.pipe(process.stderr); + } + + proc.on('exit', code => { + if (code === 0) { + resolve(); + } else { + reject(code); + } + }) + }) +} -- cgit 1.3.0-6-gf8a5