Skip to content

Commit d473f2b

Browse files
committed
update some logic for build phar
1 parent 8734d81 commit d473f2b

2 files changed

Lines changed: 15 additions & 14 deletions

File tree

app/Command/PharCommand.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -98,38 +98,39 @@ public function pack(Input $input, Output $output): int
9898
$cpr->onError(function ($error) {
9999
output()->writeln("<warning>$error</warning>");
100100
});
101+
$cpr->on(PharCompiler::ON_MESSAGE, function ($msg) {
102+
output()->colored('> ' . $msg);
103+
});
101104

102-
$counter = null;
105+
$output->colored('Collect Pack files', 'comment');
103106
if ($input->getOpt('debug')) {
104-
$output->info('Pack file to Phar ... ...');
105-
$cpr->onAdd(function ($path) {
107+
// $output->info('Pack file to Phar ... ...');
108+
$cpr->onAdd(function (string $path) {
106109
output()->writeln(" <info>+</info> $path");
107110
});
108111

109112
$cpr->on('skip', function (string $path, bool $isFile) {
110-
output()->writeln(" <red>-</red> $path" . ($isFile ? '[F]' : '[D]'));
113+
$mark = $isFile ? '[F]' : '[D]';
114+
output()->writeln(" <red>-</red> $path <info>$mark</info>");
111115
});
112116
} else {
113-
$output->info('Pack file to Phar:');
114-
$counter = Show::counterTxt('<info>File Packing ...</info>', 'Done.');
117+
$counter = Show::counterTxt('Collecting ...', 'Done.');
115118
$cpr->onAdd(function () use ($counter) {
116119
$counter->send(1);
117120
});
121+
$cpr->on(PharCompiler::ON_COLLECTED, function () use ($counter) {
122+
$counter->send(-1);
123+
});
118124
}
119125

120126
// packing ...
121127
$refresh = $input->getBoolOpt('refresh');
122128
$cpr->pack($pharFile, $refresh);
123129

124-
// end
125-
if ($counter) {
126-
$counter->send(-1);
127-
}
128-
129130
$info = [
130131
PHP_EOL . '<success>Phar Build Completed!</success>',
131-
" - Phar file: $pharFile",
132-
' - Phar size: ' . round(filesize($pharFile) / 1024 / 1024, 2) . ' Mb',
132+
" - Phar File: $pharFile",
133+
' - Phar Size: ' . round(filesize($pharFile) / 1024 / 1024, 2) . ' Mb',
133134
' - Pack Time: ' . round(microtime(true) - $startAt, 3) . ' s',
134135
' - Pack File: ' . $cpr->getCounter(),
135136
' - Commit ID: ' . $cpr->getLastCommit(),

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"ext-json": "*",
1616
"ext-mbstring": "*",
1717
"seld/phar-utils": "^1.0",
18-
"swoft/framework": "~2.0.1",
18+
"swoft/framework": "~2.0.8",
1919
"swoft/tcp": "~2.0.1",
2020
"swoft/http-server": "~2.0.0",
2121
"swoftlabs/common-devtool": "dev-master as 1.0"

0 commit comments

Comments
 (0)