Skip to content
Merged
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
11 changes: 5 additions & 6 deletions src/scheduler/cron.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,11 @@ export const Cron = {
*/
async _readCrontab() {
try {
return (
(await _execOverride("crontab -l 2>&1", {
encoding: "utf-8",
stdio: ["pipe", "pipe", "pipe"],
})) || ""
).trim();
const { stdout } = await _execOverride("crontab -l 2>&1", {
encoding: "utf-8",
stdio: ["pipe", "pipe", "pipe"],
});
return (stdout || "").trim();
} catch (_err) {
return "";
}
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/scheduler/cron.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ function mockExec(command, options) {

// Intercept crontab commands
if (command.includes("crontab -l")) {
return Promise.resolve(mockCrontabContent || "");
return Promise.resolve({ stdout: mockCrontabContent || "", stderr: "" });
}

if (command.includes("crontab -")) {
// Read from stdin (the content to install)
const stdin = options?.input || "";
mockCrontabContent = stdin;
return Promise.resolve("");
return Promise.resolve({ stdout: "", stderr: "" });
}

if (command.includes("which crontab")) {
return Promise.resolve("/usr/bin/crontab");
return Promise.resolve({ stdout: "/usr/bin/crontab", stderr: "" });
}

// Reject unknown commands to prevent hanging
Expand Down