jiek 2.1.11 → 2.1.13-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin-helper.cjs ADDED
@@ -0,0 +1,36 @@
1
+ const process = require('node:process')
2
+
3
+ /**
4
+ * @type {string | undefined}
5
+ */
6
+ let binFilePath
7
+
8
+ try {
9
+ // eslint-disable-next-line unicorn/error-message
10
+ throw new Error()
11
+ } catch (e) {
12
+ const { stack } = e
13
+ const lines = stack.split('\n')
14
+ const caller = lines[lines.length - 1]
15
+ const match = caller.match(/\(([^)]+)\)$/)
16
+ if (match) {
17
+ binFilePath = match[1].replace(/:\d+:\d+$/, '')
18
+ }
19
+ }
20
+
21
+ binFilePath = binFilePath ?? process.env.JIEK_BIN__FILEPATH
22
+
23
+ const {
24
+ basename,
25
+ dirname
26
+ } = require('node:path')
27
+
28
+ const packageDir = dirname(dirname(binFilePath))
29
+ const binFilename = basename(binFilePath).replace(/(\.[cm]?)js$/, '$1ts')
30
+
31
+ process.env.JIEK_PACKAGE_DIR = packageDir
32
+ process.env.JIEK_BIN__FILENAME = binFilename
33
+ process.env.JIEK_BIN__FILEPATH = binFilePath
34
+
35
+ require('esbuild-register')
36
+ require(`${packageDir}/src/bin/${binFilename}`)
package/bin-helper.js ADDED
@@ -0,0 +1,3 @@
1
+ import { createRequire } from 'node:module'
2
+
3
+ createRequire(import.meta.url)('./bin-helper.cjs')