Skip to content

Commit 143a651

Browse files
authored
Merge pull request #43 from markwalet/make-command-output-consistent
Make command output consistent
2 parents 34186f5 + 2d9253b commit 143a651

File tree

7 files changed

+23
-14
lines changed

7 files changed

+23
-14
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
- Add a `changelog:install` artisan command.
88
- Add a `changelog:current` artisan command.
99

10+
## Fixed
11+
- Made all command output show in a consistent manner.
12+
1013
## [v1.6.1 (2022-03-27)](https://github.com/markwalet/laravel-changelog/compare/v1.6.0...v1.6.1)
1114

1215
### Fixed

src/Commands/ChangelogCurrentCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function handle(FeatureAdapter $adapter, GitDriver $gitState)
3838

3939
return;
4040
}
41+
4142
$feature = $adapter->read($path);
4243
$this->line("Changes for $branch:");
4344

src/Commands/ChangelogGenerateCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function handle(ReleaseAdapter $adapter, ChangelogFormatterFactory $facto
4949
}
5050

5151
file_put_contents($writePath, $content);
52-
$this->info('The changelog is written to: '.$writePath);
52+
$this->info("The changelog is written to: $writePath");
5353
}
5454

5555
/**

src/Commands/ChangelogListCommand.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ public function handle(ReleaseAdapter $adapter, ChangelogFormatterFactory $facto
3636

3737
$releases = $this->releases($adapter, $path);
3838

39-
$formatted = $formatter->multiple($releases);
39+
$lines = explode(PHP_EOL, $formatter->multiple($releases));
4040

41-
$this->line($formatted);
41+
foreach ($lines as $line) {
42+
$this->line($line);
43+
}
4244
}
4345

4446
/**

src/Commands/ChangelogUnreleasedCommand.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ public function handle(ReleaseAdapter $adapter, ChangelogFormatterFactory $facto
3636

3737
$release = $this->release($adapter, $path);
3838

39-
$formatted = $formatter->single($release);
40-
$this->line($formatted);
39+
$lines = explode(PHP_EOL, $formatter->single($release));
40+
41+
foreach ($lines as $line) {
42+
$this->line($line);
43+
}
4144
}
4245

4346
/**

tests/Commands/ChangelogListCommandTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ public function it_can_list_all_changes_for_all_releases()
4646
$this->fakeAdapter();
4747

4848
$this->artisan('changelog:list')
49-
->expectsOutput('Unreleased'
50-
.PHP_EOL.' - Added: Added a new feature.'
51-
.PHP_EOL.'V1.0.1'
52-
.PHP_EOL.' - Added: Added a third feature.'
53-
.PHP_EOL.' - Added: Added helper commands.'
54-
.PHP_EOL.' - Removed: Removed unused trait.');
49+
->expectsOutput('Unreleased')
50+
->expectsOutput(' - Added: Added a new feature.')
51+
->expectsOutput('V1.0.1')
52+
->expectsOutput(' - Added: Added a third feature.')
53+
->expectsOutput(' - Added: Added helper commands.')
54+
->expectsOutput(' - Removed: Removed unused trait.');
5555
}
5656
}

tests/Commands/ChangelogUnreleasedCommandTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public function it_can_list_all_unreleased_changes()
4646
$this->fakeAdapter();
4747

4848
$this->artisan('changelog:unreleased')
49-
->expectsOutput('Unreleased'
50-
.PHP_EOL.' - Added: Added a new feature.'
51-
.PHP_EOL.' - Removed: Removed unused trait.');
49+
->expectsOutput('Unreleased')
50+
->expectsOutput(' - Added: Added a new feature.')
51+
->expectsOutput(' - Removed: Removed unused trait.');
5252
}
5353
}

0 commit comments

Comments
 (0)