diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2022-06-26 16:41:09 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2022-06-26 16:41:09 -0300 |
commit | 4075254c9e38be6741527e1fb535eed444e6ad08 (patch) | |
tree | 38c03dcb93b3a53d316b86ed9fcfc46250da208f /src/util/node-utils.js | |
parent | 0746b3a494cee55dbf90466859691c93dd8b2ca2 (diff) |
initial prettier/eslint commit
Diffstat (limited to 'src/util/node-utils.js')
-rw-r--r-- | src/util/node-utils.js | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/src/util/node-utils.js b/src/util/node-utils.js index ad87cae..889a276 100644 --- a/src/util/node-utils.js +++ b/src/util/node-utils.js @@ -1,40 +1,43 @@ // Utility functions which are only relevant to particular Node.js constructs. -import { fileURLToPath } from 'url'; +import { fileURLToPath } from "url"; -import _commandExists from 'command-exists'; +import _commandExists from "command-exists"; // This package throws an error instead of returning false when the command // doesn't exist, for some reason. Yay for making logic more difficult! // Here's a straightforward workaround. export function commandExists(command) { - return _commandExists(command).then(() => true, () => false); + return _commandExists(command).then( + () => true, + () => false + ); } // 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) + // 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); - } + 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); - } - }) - }) + proc.on("exit", (code) => { + if (code === 0) { + resolve(); + } else { + reject(code); + } + }); + }); } // Handy-dandy utility function for detecting whether the passed URL is the @@ -42,5 +45,5 @@ export function promisifyProcess(proc, showLogging = true) { // is great 'cuz (module === require.main) doesn't work without CommonJS // modules. export function isMain(importMetaURL) { - return (process.argv[1] === fileURLToPath(importMetaURL)); + return process.argv[1] === fileURLToPath(importMetaURL); } |