Skip to content
This repository was archived by the owner on Jul 1, 2023. It is now read-only.

Commit 7b582dc

Browse files
committed
Use stdin for skip-linting process, because Windows don't support long process arguments
1 parent d2f4bfc commit 7b582dc

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

bin/skip-linting.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
2-
array_shift($_SERVER['argv']);
3-
$files = $_SERVER['argv'];
2+
$stdin = fopen('php://stdin', 'r');
43

5-
foreach ($files as $file) {
4+
while($file = fgets($stdin)) {
65
$skip = false;
6+
$file = rtrim($file);
77
$f = @fopen($file, 'r');
88
if ($f) {
99
$firstLine = fgets($f);
@@ -17,4 +17,6 @@
1717
}
1818

1919
echo "$file;" . ($skip ? '1' : '0') . "\n";
20-
}
20+
}
21+
22+
fclose($stdin);

src/Process.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,10 @@ class Process
5959

6060
/**
6161
* @param string $cmdLine
62+
* @param string $stdInInput
6263
* @throws \RuntimeException
6364
*/
64-
public function __construct($cmdLine)
65+
public function __construct($cmdLine, $stdInInput = null)
6566
{
6667
$descriptors = array(
6768
self::STDIN => array('pipe', self::READ),
@@ -76,6 +77,11 @@ public function __construct($cmdLine)
7677
}
7778

7879
list($stdin, $this->stdout, $this->stderr) = $pipes;
80+
81+
if ($stdInInput) {
82+
fwrite($stdin, $stdInInput);
83+
}
84+
7985
fclose($stdin);
8086
}
8187

@@ -231,9 +237,8 @@ public function __construct($phpExecutable, array $filesToCheck)
231237

232238
$cmdLine = escapeshellarg($phpExecutable);
233239
$cmdLine .= ' -n ' . escapeshellarg(__DIR__ . '/../bin/skip-linting.php');
234-
$cmdLine .= ' ' . implode(' ', array_map('escapeshellarg', $filesToCheck));
235240

236-
parent::__construct($cmdLine);
241+
parent::__construct($cmdLine, implode("\n", $filesToCheck));
237242
}
238243

239244
public function getChunk()

0 commit comments

Comments
 (0)