inject_plugins.dart 1.26 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4 5 6
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';

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

class InjectPluginsCommand extends FlutterCommand {
13
  InjectPluginsCommand() {
14 15 16 17 18 19 20 21 22 23
    requiresPubspecYaml();
  }

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

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

  @override
24
  final bool hidden = true;
25

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
    await refreshPluginsList(project, checkProjects: true);
33
    await injectPlugins(project, checkProjects: true);
34
    final bool result = hasPlugins(project);
35
    if (result) {
36
      globals.printStatus('GeneratedPluginRegistrants successfully written.');
37
    } else {
38
      globals.printStatus('This project does not use plugins, no GeneratedPluginRegistrants have been created.');
39
    }
40

41
    return FlutterCommandResult.success();
42 43
  }
}