gro_helpers.ts

Declarations
#

2 declarations

view source

resolve_gro_module_path
#

gro_helpers.ts view source

(path?: string): string

Resolves a path to an internal Gro file. Prefers any local installation of Gro and falls back to the current CLI context.

Uses heuristics to find path, so may fail in some rare corner cases. Currently looks for gro.js as a sibling to the path arg for detection. If this fails for your usecases, rename gro.js or open an issue/PR!

Used by the CLI and gro run.

case 1:

We're in a directory that has a local installation of Gro at node_modules/.bin/gro. Use this local version instead of the global.

case 2:

We're running Gro inside the Gro repo itself.

In this case, we use the build directory instead of dist. There's a paradox here for using Gro inside itself - ideally we use the dist directory because that's what's shipped, but the build directory has all of the tests, and loading two instances of its modules causes problems like instanceof checks failing. For now we'll just run from build and see if it causes any problems. There's probably a better design in here somewhere.

case 3:

Fall back to invoking Gro from wherever the CLI is being executed. When using the global CLI, this uses the global Gro installation.

path

type string
default ''

returns

string

spawn_with_loader
#

gro_helpers.ts view source

(loader_path: string, invoke_path: string, argv: string[], js_cli?: string): Promise<SpawnResult>

Runs a file using the Gro loader.

Uses conditional exports to correctly set up esm-env as development by default, so if you want production set NODE_ENV=production.

loader_path

path to loader

type string

invoke_path

path to file to spawn with node

type string

argv

type string[]

js_cli

type string
default JS_CLI_DEFAULT

returns

Promise<SpawnResult>

see also

Depends on
#

Imported by
#