summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2022-07-31 11:13:17 +0300
committerAndrew Dolgov <[email protected]>2022-07-31 11:13:17 +0300
commitd5c043e8467881c00b2cd836f2f37b8479cf0b96 (patch)
treefdc6e27550f3ea6d327d70f2eda8ceac8450b539
parentff1845320583f6ed8c831eade58ba3b841815a48 (diff)
rework phpstan task to use inotifywait
-rw-r--r--.vscode/tasks.json21
-rw-r--r--utils/phpstan-watcher.sh18
2 files changed, 21 insertions, 18 deletions
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index a5aa65f30..0039fef88 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -3,11 +3,11 @@
"tasks": [
{
"type": "shell",
- "label": "phpstan-8.1 (background)",
+ "label": "phpstan 8.1 (watcher)",
"isBackground": true,
"problemMatcher": {
"fileLocation": ["relative", "${workspaceRoot}"],
- "owner": "phpstan-8.1",
+ "owner": "phpstan-watcher-8.1",
"pattern": {
"regexp": "^/app/(.*?):([0-9\\?]*):(.*)$",
"file": 1,
@@ -21,22 +21,7 @@
}
},
- "command": "while true; do docker run --rm -v $(pwd):/app -v /tmp/phpstan-8.1:/tmp/phpstan --workdir /app php:8.1-cli php -d memory_limit=-1 ./vendor/bin/phpstan --memory-limit=2G --error-format=raw || true; echo 'All done'; sleep 30; done",
- },
- {
- "type": "shell",
- "label": "phpstan-8.0 (run once)",
- "problemMatcher": {
- "fileLocation": ["relative", "${workspaceRoot}"],
- "owner": "phpstan-8.0",
- "pattern": {
- "regexp": "^/app/(.*?):([0-9\\?]*):(.*)$",
- "file": 1,
- "line": 2,
- "message": 3
- }
- },
- "command": "docker run --rm -v $(pwd):/app -v /tmp/phpstan-8.0:/tmp/phpstan --workdir /app php:8.0-cli php -d memory_limit=-1 ./vendor/bin/phpstan --memory-limit=2G --error-format=raw || true",
+ "command": "${workspaceRoot}/utils/phpstan-watcher.sh",
},
{
"type": "gulp",
diff --git a/utils/phpstan-watcher.sh b/utils/phpstan-watcher.sh
new file mode 100644
index 000000000..d1acc906f
--- /dev/null
+++ b/utils/phpstan-watcher.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+PHP_VERSION="$1"
+
+[ -z "$PHP_VERSION" ] && PHP_VERSION=8.1
+
+echo PHP_VERSION: ${PHP_VERSION}
+echo PWD: $(pwd)
+
+while true; do
+ inotifywait . -e close_write -r -t 300 | grep -q .php && \
+ (
+ docker run --rm -v $(pwd):/app -v /tmp/phpstan-8.1:/tmp/phpstan \
+ --workdir /app php:${PHP_VERSION}-cli php -d memory_limit=-1 ./vendor/bin/phpstan --memory-limit=2G --error-format=raw
+ echo All done, RC=$?.
+ )
+ sleep 1
+done