Use unicode (if available) when drawing file-lists (#3541)
diff --git a/lib/src/ascii_tree.dart b/lib/src/ascii_tree.dart index 1ab8a23..a63d623 100644 --- a/lib/src/ascii_tree.dart +++ b/lib/src/ascii_tree.dart
@@ -2,7 +2,8 @@ // 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. -/// A simple library for rendering tree-like structures in ASCII. +/// A simple library for rendering tree-like structures in Unicode symbols with +/// a fallback to ASCII. import 'dart:io'; import 'package:path/path.dart' as path; @@ -121,9 +122,9 @@ buffer.write(prefix); if (name != null) { if (isLastChild) { - buffer.write(log.gray("'-- ")); + buffer.write(log.gray(emoji('└── ', "'-- "))); } else { - buffer.write(log.gray('|-- ')); + buffer.write(log.gray(emoji('├── ', '|-- '))); } } @@ -134,7 +135,7 @@ String _getPrefix(bool isRoot, bool isLast) { if (isRoot) return ''; if (isLast) return ' '; - return log.gray('| '); + return log.gray(emoji('│ ', '| ')); } void _draw(
diff --git a/test/deps_test.dart b/test/deps_test.dart index 7336f13..b4ded45 100644 --- a/test/deps_test.dart +++ b/test/deps_test.dart
@@ -112,20 +112,20 @@ await runPub(args: ['deps'], output: ''' Dart SDK 0.1.2+3 myapp 0.0.0 - |-- from_path 1.2.3 - |-- normal 1.2.3 - | |-- circular_a 1.2.3 - | | '-- circular_b 1.2.3 - | | '-- circular_a... - | '-- transitive 1.2.3 - | '-- shared... - |-- overridden 2.0.0 - |-- override_only 1.2.3 - '-- unittest 1.2.3 - |-- dev_only 1.2.3 - '-- shared 1.2.3 - '-- other 1.0.0 - '-- myapp... + ├── from_path 1.2.3 + ├── normal 1.2.3 + │ ├── circular_a 1.2.3 + │ │ └── circular_b 1.2.3 + │ │ └── circular_a... + │ └── transitive 1.2.3 + │ └── shared... + ├── overridden 2.0.0 + ├── override_only 1.2.3 + └── unittest 1.2.3 + ├── dev_only 1.2.3 + └── shared 1.2.3 + └── other 1.0.0 + └── myapp... '''); }); test('in json form', () async { @@ -333,17 +333,17 @@ 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 - | |-- circular_a 1.2.3 - | | '-- circular_b 1.2.3 - | | '-- circular_a... - | '-- transitive 1.2.3 - | '-- shared 1.2.3 - | '-- other 1.0.0 - | '-- myapp... - |-- overridden 2.0.0 - '-- override_only 1.2.3 + ├── from_path 1.2.3 + ├── normal 1.2.3 + │ ├── circular_a 1.2.3 + │ │ └── circular_b 1.2.3 + │ │ └── circular_a... + │ └── transitive 1.2.3 + │ └── shared 1.2.3 + │ └── other 1.0.0 + │ └── myapp... + ├── overridden 2.0.0 + └── override_only 1.2.3 '''); }); });
diff --git a/test/lish/dot_folder_name_test.dart b/test/lish/dot_folder_name_test.dart index 9f64839..e48c541 100644 --- a/test/lish/dot_folder_name_test.dart +++ b/test/lish/dot_folder_name_test.dart
@@ -20,8 +20,8 @@ await runPub( args: ['lish', '--dry-run'], output: contains(''' -|-- .vscode -| '-- a'''), +├── .vscode +│ └── a'''), exitCode: exit_codes.SUCCESS, ); });
diff --git a/test/testdata/goldens/ascii_tree_test/tree.fromFiles a complex example.ans b/test/testdata/goldens/ascii_tree_test/tree.fromFiles a complex example.ans index 4ae381f..7b913f0 100644 --- a/test/testdata/goldens/ascii_tree_test/tree.fromFiles a complex example.ans +++ b/test/testdata/goldens/ascii_tree_test/tree.fromFiles a complex example.ans
@@ -1,26 +1,26 @@ # GENERATED BY: test/ascii_tree_test.dart -[38;5;245m|-- [0mREADME.md [38;5;245m(<1 KB)[0m -[38;5;245m|-- [0mTODO [38;5;245m(<1 KB)[0m -[38;5;245m|-- [0mexample -[38;5;245m| [0m[38;5;245m|-- [0mconsole_example.dart [38;5;245m(<1 KB)[0m -[38;5;245m| [0m[38;5;245m|-- [0mmain.dart [38;5;245m(1 KB)[0m -[38;5;245m| [0m[38;5;245m'-- [0mweb copy -[38;5;245m| [0m [38;5;245m'-- [0mweb_example.dart [38;5;245m(1 KB)[0m -[38;5;245m|-- [0mlib -[38;5;245m| [0m[38;5;245m'-- [0mpath.dart [38;5;245m(<1 KB)[0m -[38;5;245m|-- [0mpubspec.yaml [38;5;245m(<1 KB)[0m -[38;5;245m'-- [0mtest - [38;5;245m|-- [0mabsolute_test.dart [38;5;245m(<1 KB)[0m - [38;5;245m|-- [0mall_test.dart [38;5;245m(<1 KB)[0m - [38;5;245m|-- [0mbasename_test.dart [33m(1 MB)[39m - [38;5;245m|-- [0mdirname_test.dart [33m(1 MB)[39m - [38;5;245m|-- [0mextension_test.dart [38;5;245m(2 KB)[0m - [38;5;245m|-- [0mis_absolute_test.dart [38;5;245m(2 KB)[0m - [38;5;245m|-- [0mis_relative_test.dart [33m(25 MB)[39m - [38;5;245m|-- [0mjoin_test.dart [38;5;245m(<1 KB)[0m - [38;5;245m|-- [0mnormalize_test.dart [38;5;245m(1023 KB)[0m - [38;5;245m|-- [0mpath_posix_test.dart [38;5;245m(<1 KB)[0m - [38;5;245m|-- [0mpath_windows_test.dart [38;5;245m(<1 KB)[0m - [38;5;245m|-- [0mrelative_test.dart [38;5;245m(<1 KB)[0m - [38;5;245m'-- [0msplit_test.dart [38;5;245m(<1 KB)[0m +[38;5;245m├── [0mREADME.md [38;5;245m(<1 KB)[0m +[38;5;245m├── [0mTODO [38;5;245m(<1 KB)[0m +[38;5;245m├── [0mexample +[38;5;245m│ [0m[38;5;245m├── [0mconsole_example.dart [38;5;245m(<1 KB)[0m +[38;5;245m│ [0m[38;5;245m├── [0mmain.dart [38;5;245m(1 KB)[0m +[38;5;245m│ [0m[38;5;245m└── [0mweb copy +[38;5;245m│ [0m [38;5;245m└── [0mweb_example.dart [38;5;245m(1 KB)[0m +[38;5;245m├── [0mlib +[38;5;245m│ [0m[38;5;245m└── [0mpath.dart [38;5;245m(<1 KB)[0m +[38;5;245m├── [0mpubspec.yaml [38;5;245m(<1 KB)[0m +[38;5;245m└── [0mtest + [38;5;245m├── [0mabsolute_test.dart [38;5;245m(<1 KB)[0m + [38;5;245m├── [0mall_test.dart [38;5;245m(<1 KB)[0m + [38;5;245m├── [0mbasename_test.dart [33m(1 MB)[39m + [38;5;245m├── [0mdirname_test.dart [33m(1 MB)[39m + [38;5;245m├── [0mextension_test.dart [38;5;245m(2 KB)[0m + [38;5;245m├── [0mis_absolute_test.dart [38;5;245m(2 KB)[0m + [38;5;245m├── [0mis_relative_test.dart [33m(25 MB)[39m + [38;5;245m├── [0mjoin_test.dart [38;5;245m(<1 KB)[0m + [38;5;245m├── [0mnormalize_test.dart [38;5;245m(1023 KB)[0m + [38;5;245m├── [0mpath_posix_test.dart [38;5;245m(<1 KB)[0m + [38;5;245m├── [0mpath_windows_test.dart [38;5;245m(<1 KB)[0m + [38;5;245m├── [0mrelative_test.dart [38;5;245m(<1 KB)[0m + [38;5;245m└── [0msplit_test.dart [38;5;245m(<1 KB)[0m
diff --git a/test/testdata/goldens/ascii_tree_test/tree.fromMap a complex example.ans b/test/testdata/goldens/ascii_tree_test/tree.fromMap a complex example.ans index 75932d7..0089c11 100644 --- a/test/testdata/goldens/ascii_tree_test/tree.fromMap a complex example.ans +++ b/test/testdata/goldens/ascii_tree_test/tree.fromMap a complex example.ans
@@ -1,24 +1,24 @@ # GENERATED BY: test/ascii_tree_test.dart -[38;5;245m|-- [0m.gitignore -[38;5;245m|-- [0mREADME.md -[38;5;245m|-- [0mTODO -[38;5;245m|-- [0mexample -[38;5;245m| [0m[38;5;245m|-- [0mconsole_example.dart -[38;5;245m| [0m[38;5;245m|-- [0mmain.dart -[38;5;245m| [0m[38;5;245m'-- [0mweb copy -[38;5;245m| [0m [38;5;245m'-- [0mweb_example.dart -[38;5;245m|-- [0mlib -[38;5;245m| [0m[38;5;245m'-- [0mpath.dart -[38;5;245m|-- [0mpubspec.yaml -[38;5;245m'-- [0mtest - [38;5;245m|-- [0mabsolute_test.dart - [38;5;245m|-- [0mbasename_test.dart - [38;5;245m|-- [0mdirname_test.dart - [38;5;245m|-- [0mextension_test.dart - [38;5;245m|-- [0mis_absolute_test.dart - [38;5;245m|-- [0mis_relative_test.dart - [38;5;245m|-- [0mjoin_test.dart - [38;5;245m|-- [0mnormalize_test.dart - [38;5;245m|-- [0mrelative_test.dart - [38;5;245m'-- [0msplit_test.dart +[38;5;245m├── [0m.gitignore +[38;5;245m├── [0mREADME.md +[38;5;245m├── [0mTODO +[38;5;245m├── [0mexample +[38;5;245m│ [0m[38;5;245m├── [0mconsole_example.dart +[38;5;245m│ [0m[38;5;245m├── [0mmain.dart +[38;5;245m│ [0m[38;5;245m└── [0mweb copy +[38;5;245m│ [0m [38;5;245m└── [0mweb_example.dart +[38;5;245m├── [0mlib +[38;5;245m│ [0m[38;5;245m└── [0mpath.dart +[38;5;245m├── [0mpubspec.yaml +[38;5;245m└── [0mtest + [38;5;245m├── [0mabsolute_test.dart + [38;5;245m├── [0mbasename_test.dart + [38;5;245m├── [0mdirname_test.dart + [38;5;245m├── [0mextension_test.dart + [38;5;245m├── [0mis_absolute_test.dart + [38;5;245m├── [0mis_relative_test.dart + [38;5;245m├── [0mjoin_test.dart + [38;5;245m├── [0mnormalize_test.dart + [38;5;245m├── [0mrelative_test.dart + [38;5;245m└── [0msplit_test.dart
diff --git a/test/testdata/goldens/deps/executables_test/applies formatting before printing executables.txt b/test/testdata/goldens/deps/executables_test/applies formatting before printing executables.txt index d8448df..4c8b2b9 100644 --- a/test/testdata/goldens/deps/executables_test/applies formatting before printing executables.txt +++ b/test/testdata/goldens/deps/executables_test/applies formatting before printing executables.txt
@@ -2,20 +2,20 @@ ## Section 0 $ tree -|-- bar -| |-- bin -| | '-- qux.dart -| '-- pubspec.yaml -|-- foo -| |-- bin -| | |-- baz.dart -| | '-- foo.dart -| '-- pubspec.yaml -'-- myapp - |-- bin - | '-- myapp.dart - |-- pubspec.lock - '-- pubspec.yaml +├── bar +│ ├── bin +│ │ └── qux.dart +│ └── pubspec.yaml +├── foo +│ ├── bin +│ │ ├── baz.dart +│ │ └── foo.dart +│ └── pubspec.yaml +└── myapp + ├── bin + │ └── myapp.dart + ├── pubspec.lock + └── pubspec.yaml -------------------------------- END OF OUTPUT ---------------------------------
diff --git a/test/testdata/goldens/deps/executables_test/dev dependencies.txt b/test/testdata/goldens/deps/executables_test/dev dependencies.txt index 2d72b44..8493d62 100644 --- a/test/testdata/goldens/deps/executables_test/dev dependencies.txt +++ b/test/testdata/goldens/deps/executables_test/dev dependencies.txt
@@ -2,13 +2,13 @@ ## Section 0 $ tree -|-- foo -| |-- bin -| | '-- bar.dart -| '-- pubspec.yaml -'-- myapp - |-- pubspec.lock - '-- pubspec.yaml +├── foo +│ ├── bin +│ │ └── bar.dart +│ └── pubspec.yaml +└── myapp + ├── pubspec.lock + └── pubspec.yaml -------------------------------- END OF OUTPUT ---------------------------------
diff --git a/test/testdata/goldens/deps/executables_test/lists Dart executables, without entrypoints.txt b/test/testdata/goldens/deps/executables_test/lists Dart executables, without entrypoints.txt index a12d363..3b46fb0 100644 --- a/test/testdata/goldens/deps/executables_test/lists Dart executables, without entrypoints.txt +++ b/test/testdata/goldens/deps/executables_test/lists Dart executables, without entrypoints.txt
@@ -2,12 +2,12 @@ ## Section 0 $ tree -'-- myapp - |-- bin - | |-- bar.dart - | '-- foo.dart - |-- pubspec.lock - '-- pubspec.yaml +└── myapp + ├── bin + │ ├── bar.dart + │ └── foo.dart + ├── pubspec.lock + └── pubspec.yaml -------------------------------- END OF OUTPUT ---------------------------------
diff --git a/test/testdata/goldens/deps/executables_test/lists executables from a dependency.txt b/test/testdata/goldens/deps/executables_test/lists executables from a dependency.txt index 75a1b33..b78f99f 100644 --- a/test/testdata/goldens/deps/executables_test/lists executables from a dependency.txt +++ b/test/testdata/goldens/deps/executables_test/lists executables from a dependency.txt
@@ -2,13 +2,13 @@ ## Section 0 $ tree -|-- foo -| |-- bin -| | '-- bar.dart -| '-- pubspec.yaml -'-- myapp - |-- pubspec.lock - '-- pubspec.yaml +├── foo +│ ├── bin +│ │ └── bar.dart +│ └── pubspec.yaml +└── myapp + ├── pubspec.lock + └── pubspec.yaml -------------------------------- END OF OUTPUT ---------------------------------
diff --git a/test/testdata/goldens/deps/executables_test/lists executables only from immediate dependencies.txt b/test/testdata/goldens/deps/executables_test/lists executables only from immediate dependencies.txt index de70643..5d4cf00 100644 --- a/test/testdata/goldens/deps/executables_test/lists executables only from immediate dependencies.txt +++ b/test/testdata/goldens/deps/executables_test/lists executables only from immediate dependencies.txt
@@ -2,17 +2,17 @@ ## Section 0 $ tree -|-- baz -| |-- bin -| | '-- qux.dart -| '-- pubspec.yaml -|-- foo -| |-- bin -| | '-- bar.dart -| '-- pubspec.yaml -'-- myapp - |-- pubspec.lock - '-- pubspec.yaml +├── baz +│ ├── bin +│ │ └── qux.dart +│ └── pubspec.yaml +├── foo +│ ├── bin +│ │ └── bar.dart +│ └── pubspec.yaml +└── myapp + ├── pubspec.lock + └── pubspec.yaml -------------------------------- END OF OUTPUT ---------------------------------
diff --git a/test/testdata/goldens/deps/executables_test/overriden dependencies executables.txt b/test/testdata/goldens/deps/executables_test/overriden dependencies executables.txt index 910210e..edb3098 100644 --- a/test/testdata/goldens/deps/executables_test/overriden dependencies executables.txt +++ b/test/testdata/goldens/deps/executables_test/overriden dependencies executables.txt
@@ -2,18 +2,18 @@ ## Section 0 $ tree -|-- foo-1.0 -| |-- bin -| | '-- bar.dart -| '-- pubspec.yaml -|-- foo-2.0 -| |-- bin -| | |-- bar.dart -| | '-- baz.dart -| '-- pubspec.yaml -'-- myapp - |-- pubspec.lock - '-- pubspec.yaml +├── foo-1.0 +│ ├── bin +│ │ └── bar.dart +│ └── pubspec.yaml +├── foo-2.0 +│ ├── bin +│ │ ├── bar.dart +│ │ └── baz.dart +│ └── pubspec.yaml +└── myapp + ├── pubspec.lock + └── pubspec.yaml -------------------------------- END OF OUTPUT ---------------------------------
diff --git a/test/testdata/goldens/deps/executables_test/skips executables in sub directories.txt b/test/testdata/goldens/deps/executables_test/skips executables in sub directories.txt index 289f7c8..514e5ef 100644 --- a/test/testdata/goldens/deps/executables_test/skips executables in sub directories.txt +++ b/test/testdata/goldens/deps/executables_test/skips executables in sub directories.txt
@@ -2,13 +2,13 @@ ## Section 0 $ tree -'-- myapp - |-- bin - | |-- foo.dart - | '-- sub - | '-- bar.dart - |-- pubspec.lock - '-- pubspec.yaml +└── myapp + ├── bin + │ ├── foo.dart + │ └── sub + │ └── bar.dart + ├── pubspec.lock + └── pubspec.yaml -------------------------------- END OF OUTPUT ---------------------------------
diff --git a/test/testdata/goldens/deps/executables_test/skips non-Dart executables.txt b/test/testdata/goldens/deps/executables_test/skips non-Dart executables.txt index d4a2db3..8cf6076 100644 --- a/test/testdata/goldens/deps/executables_test/skips non-Dart executables.txt +++ b/test/testdata/goldens/deps/executables_test/skips non-Dart executables.txt
@@ -2,12 +2,12 @@ ## Section 0 $ tree -'-- myapp - |-- bin - | |-- bar.sh - | '-- foo.py - |-- pubspec.lock - '-- pubspec.yaml +└── myapp + ├── bin + │ ├── bar.sh + │ └── foo.py + ├── pubspec.lock + └── pubspec.yaml -------------------------------- END OF OUTPUT ---------------------------------
diff --git a/test/testdata/goldens/directory_option_test/commands taking a --directory~-C parameter work.txt b/test/testdata/goldens/directory_option_test/commands taking a --directory~-C parameter work.txt index 30ff534..47cbc9b 100644 --- a/test/testdata/goldens/directory_option_test/commands taking a --directory~-C parameter work.txt +++ b/test/testdata/goldens/directory_option_test/commands taking a --directory~-C parameter work.txt
@@ -94,18 +94,18 @@ ## Section 11 $ pub publish -C myapp --dry-run Publishing test_pkg 1.0.0 to http://localhost:$PORT: -|-- CHANGELOG.md (<1 KB) -|-- LICENSE (<1 KB) -|-- README.md (<1 KB) -|-- bin -| '-- app.dart (<1 KB) -|-- example -| '-- pubspec.yaml (<1 KB) -|-- example2 -| '-- pubspec.yaml (<1 KB) -|-- lib -| '-- test_pkg.dart (<1 KB) -'-- pubspec.yaml (<1 KB) +├── CHANGELOG.md (<1 KB) +├── LICENSE (<1 KB) +├── README.md (<1 KB) +├── bin +│ └── app.dart (<1 KB) +├── example +│ └── pubspec.yaml (<1 KB) +├── example2 +│ └── pubspec.yaml (<1 KB) +├── lib +│ └── test_pkg.dart (<1 KB) +└── pubspec.yaml (<1 KB) The server may enforce additional checks. [STDERR] [STDERR] Package has 0 warnings. @@ -126,5 +126,5 @@ $ pub deps -C myapp Dart SDK 1.12.0 test_pkg 1.0.0 -'-- foo 1.0.0 +└── foo 1.0.0
diff --git a/test/testdata/goldens/lish/many_files_test/displays all files.txt b/test/testdata/goldens/lish/many_files_test/displays all files.txt index 81897c2..00caea4 100644 --- a/test/testdata/goldens/lish/many_files_test/displays all files.txt +++ b/test/testdata/goldens/lish/many_files_test/displays all files.txt
@@ -1,32 +1,32 @@ # GENERATED BY: test/lish/many_files_test.dart Publishing test_pkg 1.0.0 to http://localhost:$PORT: -|-- CHANGELOG.md (<1 KB) -|-- LICENSE (<1 KB) -|-- README.md (<1 KB) -|-- lib -| |-- file_0.dart (<1 KB) -| |-- file_1.dart (<1 KB) -| |-- file_10.dart (<1 KB) -| |-- file_11.dart (<1 KB) -| |-- file_12.dart (<1 KB) -| |-- file_13.dart (<1 KB) -| |-- file_14.dart (<1 KB) -| |-- file_15.dart (<1 KB) -| |-- file_16.dart (<1 KB) -| |-- file_17.dart (<1 KB) -| |-- file_18.dart (<1 KB) -| |-- file_19.dart (<1 KB) -| |-- file_2.dart (<1 KB) -| |-- file_3.dart (<1 KB) -| |-- file_4.dart (<1 KB) -| |-- file_5.dart (<1 KB) -| |-- file_6.dart (<1 KB) -| |-- file_7.dart (<1 KB) -| |-- file_8.dart (<1 KB) -| |-- file_9.dart (<1 KB) -| '-- test_pkg.dart (<1 KB) -'-- pubspec.yaml (<1 KB) +├── CHANGELOG.md (<1 KB) +├── LICENSE (<1 KB) +├── README.md (<1 KB) +├── lib +│ ├── file_0.dart (<1 KB) +│ ├── file_1.dart (<1 KB) +│ ├── file_10.dart (<1 KB) +│ ├── file_11.dart (<1 KB) +│ ├── file_12.dart (<1 KB) +│ ├── file_13.dart (<1 KB) +│ ├── file_14.dart (<1 KB) +│ ├── file_15.dart (<1 KB) +│ ├── file_16.dart (<1 KB) +│ ├── file_17.dart (<1 KB) +│ ├── file_18.dart (<1 KB) +│ ├── file_19.dart (<1 KB) +│ ├── file_2.dart (<1 KB) +│ ├── file_3.dart (<1 KB) +│ ├── file_4.dart (<1 KB) +│ ├── file_5.dart (<1 KB) +│ ├── file_6.dart (<1 KB) +│ ├── file_7.dart (<1 KB) +│ ├── file_8.dart (<1 KB) +│ ├── file_9.dart (<1 KB) +│ └── test_pkg.dart (<1 KB) +└── pubspec.yaml (<1 KB) Publishing is forever; packages cannot be unpublished. Policy details are available at https://pub.dev/policy