Ejemplo n.º 1
0
function deactivateAndUnloadPackage(
  name: string,
  options: {|warn: boolean, reason: DisabledReasonType|},
): void {
  if (atom.packages.initialPackagesActivated === true) {
    if (options.warn) {
      const packageName = featureConfig.getPackageName();
      atom.notifications.addWarning(`Incompatible Package: ${name}`, {
        description: getWarningMessage(name, packageName, options.reason),
        dismissable: true,
      });
    }
  }

  const deactivationPromise =
    atom.packages.deactivatePackage(name) || Promise.resolve();
  deactivationPromise.then(() => {
    atom.packages.disablePackage(name);
    atom.packages.unloadPackage(name);
  });

  // This is a horrible hack to work around the fact that preloaded packages can sometimes be loaded
  // twice. See also atom/atom#14837
  // $FlowIgnore
  delete atom.packages.preloadedPackages[name];
}
Ejemplo n.º 2
0
export default function showAtomLinterWarning(): IDisposable {
  const packageName = featureConfig.getPackageName();
  return new UniversalDisposable(
    observePackageIsEnabled()
      .distinctUntilChanged()
      .switchMap(enabled => {
        if (!enabled) {
          return Observable.empty();
        }
        const notification = atom.notifications.addInfo('Choose a linter UI', {
          description:
            'You have both `linter` and `atom-ide-diagnostics` enabled, which will both ' +
            'display lint results for Linter-based packages.\n\n' +
            'To avoid duplicate results, please disable one of the packages.' +
            (packageName === 'nuclide'
              ? '\n\nNote that Flow and Hack errors are not compatible with `linter`.'
              : ''),
          dismissable: true,
          buttons: [
            {
              text: 'Disable Linter',
              onDidClick() {
                disableLinter();
              },
            },
            {
              text: 'Disable Diagnostics',
              onDidClick() {
                disableDiagnostics();
                atom.notifications.addInfo('Re-enabling Diagnostics', {
                  description:
                    'To re-enable diagnostics, please enable "Diagnostics" under the "Enabled Features" ' +
                    `section in \`${packageName}\` settings.`,
                });
              },
            },
          ],
        });
        return Observable.create(() => ({
          unsubscribe() {
            notification.dismiss();
          },
        }));
      })
      .subscribe(),
  );
}