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