Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ExecJS = sync.OnceValue(func() Executor { jsSettings := settings.Javascript.Get() pathToEngine, err := exec.LookPath(jsSettings.Engine) if err != nil { return errorExecutor(err) } return binaryExecutor(pathToEngine) })
View Source
var ExecTS = sync.OnceValue(func() Executor { jsSettings := settings.Javascript.Get() if jsSettings.Engine == "node" { loaderModule, err := ResolveGlobalImport(jsSettings.Transpiler, true) if err != nil { binaryName := strings.ReplaceAll(jsSettings.Transpiler, "/", "-") fullPath, err := exec.LookPath(binaryName) if err != nil { return errorExecutor(fmt.Errorf("transpiler %s not found: %w", jsSettings.Transpiler, err)) } if binaryName == "ts-node" || binaryName == "ts-node-esm" || binaryName == "tsx" { log.Printf("[WARN] Failed to locate loader script, may cause sub-optimal process configuration: %v", err) } return binaryExecutor(fullPath) } return func(ctx context.Context, script string, args ...string) (*exec.Cmd, error) { args = append([]string{ "--experimental-specifier-resolution=node", "--import", "file://" + loaderModule, script, }, args...) return ExecJS()(ctx, "", args...) } } else { return ExecJS() } })
View Source
var UnmarshalWrapperCJS = minify(`
const M = require('@');
let R = M['default'] ?? M;
R = typeof R == 'function' ? R(JSON.parse('$')) : R;
console.error('\x0d\x01\x02'+JSON.stringify(R)+'\x03\x03\x0a')
`)
View Source
var UnmarshalWrapperESM = minify(`
import * as M from 'file://@';
let R = M['default'] ?? M;
R = typeof R == 'function' ? R(JSON.parse('$')) : R;
console.error('\x0d\x01\x02'+JSON.stringify(R)+'\x03\x03\x0a')
`)
Functions ¶
func InstallGlobalPackage ¶
func ResolveGlobalImport ¶
Types ¶
type PackageManifest ¶
type PackageManifest struct { Exports map[string]string `json:"exports"` Path string `json:"path"` }
func ResolveGlobalPackage ¶
func ResolveGlobalPackage(packageName string, orInstall bool) (manifest PackageManifest, err error)
Click to show internal directories.
Click to hide internal directories.