Skip to content

Commit fbe1818

Browse files
committed
Prepare for next pdex
1 parent eb11e30 commit fbe1818

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

p5js/src/main/kotlin/p5jsEditor.kt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import javax.swing.JMenu
4343
class p5jsEditor(base: Base, path: String?, state: EditorState?, mode: Mode?): Editor(base, path, state, mode) {
4444

4545
val scope = CoroutineScope(Dispatchers.Default)
46+
val SHELL = System.getenv("SHELL")
4647

4748
init {
4849
scope.launch {
@@ -87,19 +88,23 @@ class p5jsEditor(base: Base, path: String?, state: EditorState?, mode: Mode?): E
8788
statusNotice("Looking for pnpm…")
8889
try {
8990
// TODO: Only an interactive shell allows me access to pnpm
90-
runCommand("/bin/bash", listOf("-ci", "pnpm -v"))
91+
runCommand(SHELL, listOf("-ci", "pnpm -v"))
9192
}
9293
catch (e: Exception) {
9394
statusNotice("pnpm not found. Installing pnpm…")
94-
runCommand("/bin/bash", listOf("-ci", "${mode?.folder}/install.sh"))
95+
runCommand("chmod", listOf("u+x", "${mode?.folder}/install.sh"))
96+
runCommand(SHELL, listOf("-ci", "${mode?.folder}/install.sh"))
9597

9698
statusNotice("Installing Node via pnpm…")
97-
runCommand("/bin/bash", listOf("-ci", "pnpm env use --global lts"))
99+
runCommand(SHELL, listOf("-ci", "pnpm env use --global lts"), onFinished = {
100+
statusNotice("Installing Node dependencies…")
101+
})
98102
}
99103

100-
statusNotice("")
101104
// --dangerously-allow-all-builds allows electron in particular to install properly
102-
runCommand("/bin/bash", listOf("-ci", "pnpm install --dangerously-allow-all-builds"))
105+
runCommand(SHELL, listOf("-ci", "pnpm install --dangerously-allow-all-builds"), onFinished = {
106+
statusNotice("All done! Enjoy p5.js mode.")
107+
})
103108
}
104109
}
105110

@@ -187,7 +192,7 @@ class p5jsEditor(base: Base, path: String?, state: EditorState?, mode: Mode?): E
187192
Button(onClick = {
188193
if (packageToInstall.isNotBlank()) {
189194
// TODO Better error handling
190-
runCommand("pnpm", listOf("add", packageToInstall, "--dangerously-allow-all-builds"))
195+
runCommand(SHELL, listOf("-ci", "pnpm add $packageToInstall --dangerously-allow-all-builds"))
191196
packageToInstall = ""
192197
}
193198
}) {

p5js/src/main/kotlin/p5jsEditorToolbar.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ class p5jsEditorToolbar(editor: p5jsEditor?) : EditorToolbar(editor) {
1313
editor.sketch.save()
1414

1515
runButton.setSelected(true)
16-
editor.runCommand("/bin/bash", listOf("-ci", "npx electron .")) {
16+
editor.statusNotice("Starting up sketch…")
17+
editor.runCommand(editor.SHELL, listOf("-ci", "npx electron .")) {
1718
runButton.setSelected(false)
1819
}
1920
}

0 commit comments

Comments
 (0)