diff options
author | (quasar) nebula <towerofnix@gmail.com> | 2021-05-06 14:56:18 -0300 |
---|---|---|
committer | (quasar) nebula <towerofnix@gmail.com> | 2021-05-06 14:56:18 -0300 |
commit | ead9bdc9fc1e9cc62a26e59f6880a13aa864f931 (patch) | |
tree | d459b47dbb17ad99615ca595bbe1e92d651eab15 /src/util/node-utils.js | |
parent | 2260541dc69c19e7444348ac3243f96e4321b781 (diff) |
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
Diffstat (limited to 'src/util/node-utils.js')
-rw-r--r-- | src/util/node-utils.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/util/node-utils.js b/src/util/node-utils.js new file mode 100644 index 00000000..d660612e --- /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); + } + }) + }) +} |