Skip to content

Commit

Permalink
Include the SDK version with "pub deps" (#1833)
Browse files Browse the repository at this point in the history
Closes #1827
  • Loading branch information
nex3 authored Mar 20, 2018
1 parent 8ac2944 commit 709a5c8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/src/command/deps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import 'package:path/path.dart' as p;
import '../ascii_tree.dart' as tree;
import '../command.dart';
import '../dart.dart';
import '../flutter.dart' as flutter;
import '../log.dart' as log;
import '../package.dart';
import '../sdk.dart' as sdk;
import '../utils.dart';

/// Returns `true` if [path] looks like a Dart entrypoint.
Expand Down Expand Up @@ -64,6 +66,12 @@ class DepsCommand extends PubCommand {
if (argResults['executables']) {
_outputExecutables();
} else {
_buffer.writeln("${log.bold('Dart SDK')} ${sdk.version}");

if (flutter.isAvailable) {
_buffer.writeln("${log.bold('Flutter SDK')} ${flutter.version}");
}

_buffer.writeln(_labelPackage(entrypoint.root));

switch (argResults["style"]) {
Expand Down
19 changes: 18 additions & 1 deletion test/deps_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:path/path.dart' as p;
import 'package:test/test.dart';

import 'descriptor.dart' as d;
Expand Down Expand Up @@ -46,6 +47,7 @@ main() {
test("in compact form", () async {
await pubGet();
await runPub(args: ['deps', '-s', 'compact'], output: '''
Dart SDK 0.1.2+3
myapp 0.0.0
dependencies:
Expand Down Expand Up @@ -73,6 +75,7 @@ main() {
test("in list form", () async {
await pubGet();
await runPub(args: ['deps', '--style', 'list'], output: '''
Dart SDK 0.1.2+3
myapp 0.0.0
dependencies:
Expand Down Expand Up @@ -106,9 +109,10 @@ main() {
''');
});

test("lists dependencies in tree form", () async {
test("in tree form", () async {
await pubGet();
await runPub(args: ['deps'], output: '''
Dart SDK 0.1.2+3
myapp 0.0.0
|-- from_path 1.2.3
|-- normal 1.2.3
Expand All @@ -126,12 +130,23 @@ main() {
'-- myapp...
''');
});

test("with the Flutter SDK, if applicable", () async {
await pubGet();

await d.dir('flutter', [d.file('version', '4.3.2+1')]).create();
await runPub(
args: ['deps'],
output: contains('Flutter SDK 4.3.2+1'),
environment: {"FLUTTER_ROOT": p.join(d.sandbox, 'flutter')});
});
});

group("lists non-dev dependencies", () {
test("in compact form", () async {
await pubGet();
await runPub(args: ['deps', '-s', 'compact', '--no-dev'], output: '''
Dart SDK 0.1.2+3
myapp 0.0.0
dependencies:
Expand All @@ -155,6 +170,7 @@ main() {
test("in list form", () async {
await pubGet();
await runPub(args: ['deps', '--style', 'list', '--no-dev'], output: '''
Dart SDK 0.1.2+3
myapp 0.0.0
dependencies:
Expand Down Expand Up @@ -185,6 +201,7 @@ main() {
test("in tree form", () async {
await pubGet();
await runPub(args: ['deps', '--no-dev'], output: '''
Dart SDK 0.1.2+3
myapp 0.0.0
|-- from_path 1.2.3
|-- normal 1.2.3
Expand Down

0 comments on commit 709a5c8

Please sign in to comment.