mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-19 13:24:51 +08:00
Allow setting suffix for licence name
This commit is contained in:
parent
33798ff108
commit
c0830a9e1f
@ -90,8 +90,8 @@ class LicenseDumper
|
||||
$licenses = [$licenses];
|
||||
}
|
||||
|
||||
foreach ($licenses as $license) {
|
||||
yield match ($license['type']) {
|
||||
foreach ($licenses as $index => $license) {
|
||||
yield ($license['suffix'] ?? $index) => match ($license['type']) {
|
||||
'text' => $license['text'],
|
||||
'file' => $this->loadSourceFile($source_name, $license['path'], Config::getSource($source_name)['path'] ?? null),
|
||||
default => throw new RuntimeException('source [' . $source_name . '] license type is not allowed'),
|
||||
|
||||
@ -37,6 +37,7 @@ final class LicenseDumperTest extends TestCase
|
||||
'license' => [
|
||||
'type' => 'text',
|
||||
'text' => 'license',
|
||||
'suffix' => 'zend',
|
||||
],
|
||||
],
|
||||
];
|
||||
@ -45,7 +46,7 @@ final class LicenseDumperTest extends TestCase
|
||||
$dumper->addLibs(['fake_lib']);
|
||||
$dumper->dump(self::DIRECTORY);
|
||||
|
||||
$this->assertFileExists(self::DIRECTORY . '/lib_fake_lib_0.txt');
|
||||
$this->assertFileExists(self::DIRECTORY . '/lib_fake_lib_zend.txt');
|
||||
}
|
||||
|
||||
public function testDumpWithMultipleLicenses(): void
|
||||
@ -66,6 +67,11 @@ final class LicenseDumperTest extends TestCase
|
||||
'type' => 'text',
|
||||
'text' => 'license',
|
||||
],
|
||||
[
|
||||
'type' => 'text',
|
||||
'text' => 'license',
|
||||
'suffix' => 'zend',
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
@ -76,5 +82,6 @@ final class LicenseDumperTest extends TestCase
|
||||
|
||||
$this->assertFileExists(self::DIRECTORY . '/lib_fake_lib_0.txt');
|
||||
$this->assertFileExists(self::DIRECTORY . '/lib_fake_lib_1.txt');
|
||||
$this->assertFileExists(self::DIRECTORY . '/lib_fake_lib_zend.txt');
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user