Skip to content

Commit 0d02d80

Browse files
authored
Revert "feat: add support for formatting code from stdin (#390)" (#402)
This reverts commit 06dca19.
1 parent e42eb38 commit 0d02d80

File tree

2 files changed

+0
-119
lines changed

2 files changed

+0
-119
lines changed

app/Commands/DefaultCommand.php

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
namespace App\Commands;
44

5-
use App\Actions\FixCode;
65
use LaravelZero\Framework\Commands\Command;
76
use Symfony\Component\Console\Input\InputArgument;
87
use Symfony\Component\Console\Input\InputOption;
9-
use Throwable;
108

119
class DefaultCommand extends Command
1210
{
@@ -64,58 +62,8 @@ protected function configure()
6462
*/
6563
public function handle($fixCode, $elaborateSummary)
6664
{
67-
if ($this->hasStdinInput()) {
68-
return $this->fixStdinInput($fixCode);
69-
}
70-
7165
[$totalFiles, $changes] = $fixCode->execute();
7266

7367
return $elaborateSummary->execute($totalFiles, $changes);
7468
}
75-
76-
/**
77-
* Fix the code sent to Pint on stdin and output to stdout.
78-
*/
79-
protected function fixStdinInput(FixCode $fixCode): int
80-
{
81-
$paths = $this->argument('path');
82-
83-
$contextPath = ! empty($paths) ? $paths[0] : 'stdin.php';
84-
$tempFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.'pint_stdin_'.uniqid().'.php';
85-
86-
$this->input->setArgument('path', [$tempFile]);
87-
$this->input->setOption('format', 'json');
88-
89-
try {
90-
file_put_contents($tempFile, stream_get_contents(STDIN));
91-
$fixCode->execute();
92-
fwrite(STDOUT, file_get_contents($tempFile));
93-
94-
return self::SUCCESS;
95-
} catch (Throwable $e) {
96-
fwrite(STDERR, "pint: error processing {$contextPath}: {$e->getMessage()}\n");
97-
98-
return self::FAILURE;
99-
} finally {
100-
if (file_exists($tempFile)) {
101-
@unlink($tempFile);
102-
}
103-
}
104-
}
105-
106-
/**
107-
* Determine if there is input available on stdin.
108-
*/
109-
protected function hasStdinInput(): bool
110-
{
111-
if ($this->option('test') || $this->option('bail') || $this->option('repair')) {
112-
return false;
113-
}
114-
115-
if (! is_resource(STDIN) || stream_isatty(STDIN)) {
116-
return false;
117-
}
118-
119-
return ! stream_get_meta_data(STDIN)['eof'];
120-
}
12169
}

tests/Feature/StdinTest.php

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)