Skip to content

Commit 0b009da

Browse files
committed
feat: add bootstrap script requirement to NODE_OPTIONS
1 parent 3b8c548 commit 0b009da

File tree

2 files changed

+43
-23
lines changed

2 files changed

+43
-23
lines changed

bin/local-action.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ function entrypoint() {
3232
? path.join(packagePath, 'src', 'bootstrap.ts').replaceAll('\\', '\\\\')
3333
: path.join(packagePath, 'src', 'bootstrap.ts')
3434

35+
// Require the bootstrap script in NODE_OPTIONS.
36+
process.env.NODE_OPTIONS = process.env.NODE_OPTIONS
37+
? `${process.env.NODE_OPTIONS} --require "${bootstrapPath}"`
38+
: `--require "${bootstrapPath}"`
39+
3540
// Disable experimental warnings.
3641
process.env.NODE_NO_WARNINGS = 1
3742

src/bootstrap.ts

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,46 @@
99
* will parse them and register them so that modules can be resolved correctly.
1010
*/
1111

12-
const { existsSync, readFileSync } = require('fs')
13-
const { loadConfig, register } = require('tsconfig-paths')
14-
const { parse } = require('comment-json')
12+
import('fs').then(({ existsSync, readFileSync }) => {
13+
import('tsconfig-paths').then(({ loadConfig, register }) => {
14+
import('comment-json').then(({ parse }) => {
15+
import('path').then(({ dirname }) => {
16+
import('url').then(({ fileURLToPath }) => {
17+
if (
18+
process.env.TARGET_ACTION_PATH &&
19+
process.env.TARGET_ACTION_PATH !== ''
20+
) {
21+
// Check if the action has a `tsconfig.json` file.
22+
if (existsSync(`${process.env.TARGET_ACTION_PATH}/tsconfig.json`)) {
23+
const __dirname = dirname(fileURLToPath(import.meta.url))
1524

16-
if (process.env.TARGET_ACTION_PATH && process.env.TARGET_ACTION_PATH !== '') {
17-
// Check if the action has a `tsconfig.json` file.
18-
if (existsSync(`${process.env.TARGET_ACTION_PATH}/tsconfig.json`)) {
19-
// Load the `tsconfig.json` from the action directory.
20-
const actionTsConfig = parse(
21-
readFileSync(`${process.env.TARGET_ACTION_PATH}/tsconfig.json`, 'utf-8')
22-
)
25+
// Load the `tsconfig.json` from the action directory.
26+
const actionTsConfig = parse(
27+
readFileSync(
28+
`${process.env.TARGET_ACTION_PATH}/tsconfig.json`,
29+
'utf-8'
30+
)
31+
)
2332

24-
// Load the current `tsconfig.json` from the root of this directory.
25-
loadConfig(__dirname)
33+
// Load the current `tsconfig.json` from the root of this directory.
34+
loadConfig(__dirname)
2635

27-
// Get the paths from the action's `tsconfig.json`, if any.
28-
const paths = actionTsConfig.compilerOptions?.paths ?? {}
36+
// Get the paths from the action's `tsconfig.json`, if any.
37+
// @ts-expect-error comment-json type mismatch
38+
const paths = actionTsConfig?.compilerOptions?.paths ?? {}
2939

30-
// Add any path mappings from the imported action. Replace the base URL with
31-
// the target action path.
32-
// @todo Should this take into account the previous `baseUrl` value?
33-
register({
34-
baseUrl: process.env.TARGET_ACTION_PATH,
35-
paths,
36-
addMatchAll: true
40+
// Add any path mappings from the imported action. Replace the base URL with
41+
// the target action path.
42+
// @todo Should this take into account the previous `baseUrl` value?
43+
register({
44+
baseUrl: process.env.TARGET_ACTION_PATH,
45+
paths,
46+
addMatchAll: true
47+
})
48+
}
49+
}
50+
})
51+
})
3752
})
38-
}
39-
}
53+
})
54+
})

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy