Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/core/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,12 @@ class Runner extends BaseRunner {
* @returns The command to be executed.
*/
private prepareCommand(env?: Record<string, string | undefined>) {
let child = $.raw`${this.processConfig.cmd!}`.stdout("piped").stderr("piped")
// Execute command through a shell to handle complex commands like "deno task",
// pipes, redirects, and other shell features
const shell = CurrentOS === OperatingSystem.Windows ? "cmd" : "sh"
const shellArg = CurrentOS === OperatingSystem.Windows ? "/c" : "-c"

let child = $`${shell} ${shellArg} ${this.processConfig.cmd!}`.stdout("piped").stderr("piped")

if (this.processConfig.cwd) child = child.cwd(this.processConfig.cwd)
if (env) child = child.env(env)
Expand Down
5 changes: 5 additions & 0 deletions lib/test/core/test-data/deno-task-test/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tasks": {
"hello": "deno run hello.ts"
}
}
1 change: 1 addition & 0 deletions lib/test/core/test-data/deno-task-test/hello.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("hello-from-deno-task")
32 changes: 32 additions & 0 deletions test/core/runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,35 @@ test("Runner handles commands with pipes and redirects", async () => {
// Stop and cleanup
await pup.terminate(2500)
})

test("Runner executes actual 'deno task' commands correctly (issue #55)", async () => {
const TEST_PROCESS_ID = "test-actual-deno-task"
const TEST_PROCESS_COMMAND = "deno task hello"
const TEST_CWD = new URL("../../lib/test/core/test-data/deno-task-test/", import.meta.url).pathname

const config: Configuration = {
processes: [
{
"id": TEST_PROCESS_ID,
"cmd": TEST_PROCESS_COMMAND,
"cwd": TEST_CWD,
},
],
}
const pup = new Pup(config)
await pup.init()

// Find process
const testProcess = pup.processes.findLast((p) => p.getConfig().id === TEST_PROCESS_ID)
assertEquals(testProcess !== undefined, true)

// Start process
const startResult = pup.start(TEST_PROCESS_ID, "test")
assertEquals(startResult, true)

// Wait a moment for process to complete
await new Promise((resolve) => setTimeout(resolve, 1000))

// Stop and cleanup
await pup.terminate(2500)
})