@emeryld/manager 0.1.0 → 0.1.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/manager-cli.js +5 -1
- package/package.json +1 -1
- package/src/helper-cli.ts +10 -1
package/bin/manager-cli.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { spawnSync } from 'node:child_process'
|
|
3
3
|
import path from 'node:path'
|
|
4
4
|
import { fileURLToPath } from 'node:url'
|
|
5
|
+
import { createRequire } from 'node:module'
|
|
5
6
|
|
|
6
7
|
const __filename = fileURLToPath(import.meta.url)
|
|
7
8
|
const __dirname = path.dirname(__filename)
|
|
@@ -9,7 +10,10 @@ const packageRoot = path.resolve(__dirname, '..')
|
|
|
9
10
|
const tsconfigPath = path.join(packageRoot, 'tsconfig.base.json')
|
|
10
11
|
const entryPoint = path.join(packageRoot, 'src', 'publish.ts')
|
|
11
12
|
|
|
12
|
-
const
|
|
13
|
+
const require = createRequire(import.meta.url)
|
|
14
|
+
const tsNodeLoader = require.resolve('ts-node/esm.mjs')
|
|
15
|
+
|
|
16
|
+
const nodeArgs = ['--loader', tsNodeLoader, entryPoint, ...process.argv.slice(2)]
|
|
13
17
|
const execOptions = {
|
|
14
18
|
env: { ...process.env, TS_NODE_PROJECT: tsconfigPath },
|
|
15
19
|
stdio: 'inherit',
|
package/package.json
CHANGED
package/src/helper-cli.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process'
|
|
2
|
+
import { createRequire } from 'node:module'
|
|
2
3
|
import readline from 'node:readline/promises'
|
|
3
4
|
import { stdin as input, stdout as output } from 'node:process'
|
|
4
5
|
import { fileURLToPath } from 'node:url'
|
|
@@ -6,6 +7,14 @@ import path from 'node:path'
|
|
|
6
7
|
|
|
7
8
|
const __filename = fileURLToPath(import.meta.url)
|
|
8
9
|
const rootDir = path.resolve(path.dirname(__filename), '..')
|
|
10
|
+
const managerRequire = createRequire(import.meta.url)
|
|
11
|
+
let tsNodeLoaderPath: string | undefined
|
|
12
|
+
function getTsNodeLoaderPath() {
|
|
13
|
+
if (!tsNodeLoaderPath) {
|
|
14
|
+
tsNodeLoaderPath = managerRequire.resolve('ts-node/esm.mjs')
|
|
15
|
+
}
|
|
16
|
+
return tsNodeLoaderPath
|
|
17
|
+
}
|
|
9
18
|
|
|
10
19
|
const ansi = (code: number) => (text: string) => `\x1b[${code}m${text}\x1b[0m`
|
|
11
20
|
const colors = {
|
|
@@ -306,7 +315,7 @@ function runEntry(entry: ResolvedScriptEntry, forwardedArgs: string[]) {
|
|
|
306
315
|
const isTypeScript = extension === '.ts' || extension === '.mts' || extension === '.cts'
|
|
307
316
|
const command = process.execPath
|
|
308
317
|
const execArgs = isTypeScript
|
|
309
|
-
? ['--loader',
|
|
318
|
+
? ['--loader', getTsNodeLoaderPath(), scriptPath, ...forwardedArgs]
|
|
310
319
|
: [scriptPath, ...forwardedArgs]
|
|
311
320
|
return new Promise<void>((resolve, reject) => {
|
|
312
321
|
const child = spawn(command, execArgs, {
|