inject_plugins.dart 1.22 KB
Newer Older
1 2 3 4 5 6 7 8
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';

import '../globals.dart';
import '../plugins.dart';
9
import '../project.dart';
10 11 12
import '../runner/flutter_command.dart';

class InjectPluginsCommand extends FlutterCommand {
13
  InjectPluginsCommand({ this.hidden = false }) {
14 15 16 17 18 19 20 21 22 23 24 25
    requiresPubspecYaml();
  }

  @override
  final String name = 'inject-plugins';

  @override
  final String description = 'Re-generates the GeneratedPluginRegistrants.';

  @override
  final bool hidden;

26 27 28
  @override
  Future<Set<DevelopmentArtifact>> get requiredArtifacts async => const <DevelopmentArtifact>{};

29
  @override
30
  Future<FlutterCommandResult> runCommand() async {
31
    final FlutterProject project = FlutterProject.current();
32 33
    refreshPluginsList(project, checkProjects: true);
    await injectPlugins(project, checkProjects: true);
34
    final bool result = hasPlugins(project);
35 36 37 38 39
    if (result) {
      printStatus('GeneratedPluginRegistrants successfully written.');
    } else {
      printStatus('This project does not use plugins, no GeneratedPluginRegistrants have been created.');
    }
40 41

    return null;
42 43
  }
}