enable method

void enable()

Implementation

void enable() {
  if (_enabled) return;

  _backup(_pubspecPath);
  _backup(_testEntryPath, optional: true);

  final priorTestEntry = _backups[_testEntryPath] ?? '';
  _removeTestEntryOnRestore =
      priorTestEntry.isEmpty || priorTestEntry == testEntryContents;

  final pubspec = File(_pubspecPath).readAsStringSync();
  final activated = _activatePubspec(pubspec);
  _pubspecChanged = activated != pubspec;
  if (_pubspecChanged) {
    File(_pubspecPath).writeAsStringSync(activated);
  }

  Directory(_testDirPath).createSync(recursive: true);
  final testEntry = File(_testEntryPath);
  if (!testEntry.existsSync() ||
      testEntry.readAsStringSync() != testEntryContents) {
    testEntry.writeAsStringSync(testEntryContents);
  }

  _enabled = true;
}