Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicatarra committed Aug 20, 2024
1 parent a4483c4 commit 01898ef
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 26 deletions.
1 change: 0 additions & 1 deletion packages/melos/lib/src/commands/format.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ mixin _FormatMixin on _Melos {
}

exitCode = 1;
throw SilenceException();
}

Future<int> _formatForPackage(
Expand Down
46 changes: 21 additions & 25 deletions packages/melos/test/commands/format_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,14 @@ $ melos format
''',
);

final result = await Process.run(
final process = await Process.start(
'melos',
['format', '--set-exit-if-changed'],
workingDirectory: workspaceDir.path,
runInShell: Platform.isWindows,
stdoutEncoding: utf8,
stderrEncoding: utf8,
);

expect(result.exitCode, isNot(equals(0)));
expect(await process.exitCode, equals(1));
});

test('should run format with --output show flag', () async {
Expand Down Expand Up @@ -177,18 +175,16 @@ $ melos format
''',
);

final result = await Process.run(
final process = await Process.start(
'melos',
['format', '--output', 'none', '--set-exit-if-changed'],
workingDirectory: workspaceDir.path,
runInShell: Platform.isWindows,
stdoutEncoding: utf8,
stderrEncoding: utf8,
);

expect(result.exitCode, isNot(equals(0)));
expect(await process.exitCode, equals(1));
expect(
result.stdout,
process.stdout,
ignoringAnsii(r'''
Resolving dependencies...
+ ansi_styles 0.3.2+1
Expand Down Expand Up @@ -279,19 +275,19 @@ void main() {
code,
);

final result = await Process.run(
final process = await Process.start(
'melos',
['format', '--set-exit-if-changed', '--line-length', '150'],
workingDirectory: workspaceDir.path,
runInShell: Platform.isWindows,
stdoutEncoding: utf8,
stderrEncoding: utf8,
);

expect(result.exitCode, equals(0));
final exitCode = await process.exitCode;

expect(exitCode, equals(0));

expect(
result.stdout,
await utf8.decodeStream(process.stdout),
contains(
r'''
$ melos format
Expand Down Expand Up @@ -334,19 +330,19 @@ void main() {
code,
);

final result = await Process.run(
final process = await Process.start(
'melos',
['format', '--set-exit-if-changed'],
workingDirectory: workspaceDir.path,
runInShell: Platform.isWindows,
stdoutEncoding: utf8,
stderrEncoding: utf8,
);

expect(result.exitCode, equals(0));
final exitCode = await process.exitCode;

expect(exitCode, equals(0));

expect(
result.stdout,
await utf8.decodeStream(process.stdout),
contains(
r'''
$ melos format
Expand Down Expand Up @@ -388,21 +384,21 @@ void main() {
code,
);

final result = await Process.run(
final process = await Process.start(
'melos',
['format'],
workingDirectory: workspaceDir.path,
runInShell: Platform.isWindows,
stdoutEncoding: utf8,
stderrEncoding: utf8,
);

expect(result.exitCode, isNot(equals(0)));
final stdoutString = await utf8.decodeStream(process.stdout);

expect(await process.exitCode, equals(1));

expect(result.stdout, contains('Formatted 1 file (1 changed)'));
expect(stdoutString, contains('Formatted 1 file (1 changed)'));

expect(
result.stdout,
stdoutString,
contains(
r'''
$ melos format
Expand Down

0 comments on commit 01898ef

Please sign in to comment.