isGloballyActivated method

bool isGloballyActivated(
  1. String packageName
)

returns true if the given package has been globally activated

Implementation

bool isGloballyActivated(String packageName) {
  const notFound = r'123!!23172@@#$!@!#';

  /// run pub global list to see if dcli is run from a local path.
  final line = DartSdk()
      .runPub(args: ['global', 'list'], progress: Progress.capture())
      .lines
      .firstWhere((line) => line.startsWith(packageName),
          orElse: () => notFound);

  return line.contains(packageName);
}