Skip to content

Commit b1a04fe

Browse files
committed
fix: Psysh now stops waiting for input because of calling the exit command by throwing a BreakException
Closes #162
1 parent e3f35f2 commit b1a04fe

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

CHANGELOG.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
77
## [Unreleased]
88
### Fixed
99
- [[#46]](https://github.com/Roboroads/laravel-tinker/issues/46) Execution on docker
10-
- ℹ️ This does not fix the "string conversion" error found when using `docker exec`. You still have to use `docker run` for now.
11-
- [[#162]](https://github.com/Roboroads/laravel-tinker/issues/162) ~~Fixes~~ Workarounds endless execution of the tinker process.
12-
- Compatibility issue with JB version 2022.2 regarding `ContentFactory.SERVICE`
10+
- ℹ️This does not fix the "string conversion" error found when using `docker exec`. You still have to use `docker run` for now.
11+
- [[#162]](https://github.com/Roboroads/laravel-tinker/issues/162) Endless execution of the tinker process in several usecases (like JB 2022.2 EAP)
12+
- Compatibility issue with JB 2022.2 (EAP) regarding `ContentFactory.SERVICE`
1313

1414
## [2.3.3]
1515
### Removed
1616
- [[#136]](https://github.com/Roboroads/laravel-tinker/issues/136) Upper version limit for JB products.
17-
- ℹ️This will enable the plugin to be compatible for all JB products >= 211 until a compatibility issue shows up.
17+
- ℹ This will enable the plugin to be compatible for all JB products >= 211 until a compatibility issue shows up.
1818

1919
## [2.3.2]
2020
### Changed

src/main/kotlin/nl/deschepers/laraveltinker/listener/PhpProcessListener.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class PhpProcessListener(private val project: Project, private val processHandle
1919
companion object {
2020
private const val OUTPUT_START_SEQUENCE = "%%START-OUTPUT%%"
2121
private const val OUTPUT_END_SEQUENCE = "%%END-OUTPUT%%"
22-
private const val OUTPUT_EOT_PROMPT = "%%EOT%%"
2322
private const val SUPPORT_MESSAGE_EXECUTIONS = 10
2423
}
2524

@@ -58,17 +57,14 @@ class PhpProcessListener(private val project: Project, private val processHandle
5857
}
5958

6059
override fun onTextAvailable(event: ProcessEvent, outputType: Key<*>) {
60+
// print(event.text) //DEBUG: Print full command output to console
6161
if (firstLine) {
6262
firstLine = false
6363
return
6464
}
6565

6666
var capText = event.text
6767

68-
if (capText == OUTPUT_EOT_PROMPT) {
69-
processHandler.destroyProcess()
70-
}
71-
7268
if (!capturing && capText.contains(OUTPUT_START_SEQUENCE)) {
7369
capText =
7470
capText.substring(
@@ -77,8 +73,6 @@ class PhpProcessListener(private val project: Project, private val processHandle
7773
capturing = true
7874
}
7975
if (capturing && capText.contains(OUTPUT_END_SEQUENCE)) {
80-
capText = capText.substring(0, capText.indexOf(OUTPUT_END_SEQUENCE))
81-
processOutput.add(capText)
8276
capturing = false
8377
}
8478

src/main/resources/scripts/tinker_run.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
'updateCheck' => 'never',
1414
'usePcntl' => false,
1515
'useReadline' => false,
16-
'prompt' => '%%EOT%%'
16+
'prompt' => '%%END-OUTPUT%%'
1717
]);
1818

1919
$casters = [
@@ -59,7 +59,8 @@
5959
$sanitizedRunCode .= $token;
6060
}
6161

62-
$shell->addInput($sanitizedRunCode . "; exit('%%END-OUTPUT%%');", true);
62+
$shell->addInput($sanitizedRunCode, true);
63+
$shell->addInput('throw new \Psy\Exception\BreakException("%%END-OUTPUT%%");', true);
6364
$closure = new \Psy\ExecutionLoopClosure($shell);
6465
$closure->execute();
6566

src/main/resources/strings/strings.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ lt.run=Run Tinker
33
lt.running=Running Tinker console..
44
lt.tinker.output=Tinker Output:
55
lt.started.at=// Laravel Tinker started at {0}
6-
lt.execution.finished=*** Execution finished ***
6+
lt.execution.finished=\n*** Execution finished ***
77
lt.consider.supporting=Does the Laravel Tinker plugin help you being productive?\nConsider <a href="https://www.patreon.com/roboroads">supporting it</a>.
88

99
lt.settings.php_interpreter=PHP interpreter settings

0 commit comments

Comments
 (0)