registerGlobalVariables static method

void registerGlobalVariables(
  1. D4rt interpreter,
  2. String importPath
)

Registers all global variables with the interpreter.

importPath is the package import path for library-scoped registration. Collects all registration errors and throws a single exception with all error details if any registrations fail.

Implementation

static void registerGlobalVariables(D4rt interpreter, String importPath) {
  final errors = <String>[];

  try {
    interpreter.registerGlobalVariable('installFromSourceKey', $dcli_18.installFromSourceKey, importPath, sourceUri: 'package:dcli/src/installers/installer.dart');
  } catch (e) {
    errors.add('Failed to register variable "installFromSourceKey": $e');
  }
  try {
    interpreter.registerGlobalVariable('overrideDCliPathKey', $dcli_22.overrideDCliPathKey, importPath, sourceUri: 'package:dcli/src/script/dart_project.dart');
  } catch (e) {
    errors.add('Failed to register variable "overrideDCliPathKey": $e');
  }
  interpreter.registerGlobalGetter('env', () => $dcli_core_9.env, importPath, sourceUri: 'package:dcli_core/src/functions/env.dart');
  interpreter.registerGlobalGetter('PATH', () => $dcli_core_9.PATH, importPath, sourceUri: 'package:dcli_core/src/functions/env.dart');
  interpreter.registerGlobalGetter('HOME', () => $dcli_core_9.HOME, importPath, sourceUri: 'package:dcli_core/src/functions/env.dart');
  interpreter.registerGlobalGetter('envs', () => $dcli_core_9.envs, importPath, sourceUri: 'package:dcli_core/src/functions/env.dart');
  interpreter.registerGlobalGetter('pwd', () => $dcli_core_15.pwd, importPath, sourceUri: 'package:dcli_core/src/functions/pwd.dart');
  interpreter.registerGlobalGetter('eol', () => $dcli_core_23.eol, importPath, sourceUri: 'package:dcli_core/src/util/platform.dart');
  interpreter.registerGlobalGetter('rootPath', () => $dcli_core_26.rootPath, importPath, sourceUri: 'package:dcli_core/src/util/truepath.dart');
  interpreter.registerGlobalGetter('fileList', () => $dcli_7.fileList, importPath, sourceUri: 'package:dcli/src/functions/file_list.dart');

  if (errors.isNotEmpty) {
    throw StateError('Bridge registration errors (dcli):\n${errors.join("\n")}');
  }
}