From 7ffc79f9c891becdcf778ab6e5faf4c8ca3b14da Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 27 Feb 2022 11:14:54 -0400 Subject: let gen-thumbs be run directly --- src/util/node-utils.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/util/node-utils.js') diff --git a/src/util/node-utils.js b/src/util/node-utils.js index d660612e..a46d6141 100644 --- a/src/util/node-utils.js +++ b/src/util/node-utils.js @@ -1,5 +1,7 @@ // Utility functions which are only relevant to particular Node.js constructs. +import { fileURLToPath } from 'url'; + // 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) { @@ -25,3 +27,11 @@ export function promisifyProcess(proc, showLogging = true) { }) }) } + +// Handy-dandy utility function for detecting whether the passed URL is the +// running JavaScript file. This takes `import.meta.url` from ES6 modules, which +// is great 'cuz (module === require.main) doesn't work without CommonJS +// modules. +export function isMain(importMetaURL) { + return (process.argv[1] === fileURLToPath(importMetaURL)); +} -- cgit 1.3.0-6-gf8a5