Skip to content

Commit

Permalink
feat(core-cli): implement trigger method in ProcessManager (#3736)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastijankuzner authored May 25, 2020
1 parent c52b6ab commit cf8a401
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
18 changes: 18 additions & 0 deletions __tests__/unit/core-cli/services/process-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,24 @@ describe("ProcessManager", () => {
});
});

describe("#trigger", () => {
it(".trigger()", () => {
// Arrange...
const spySync: jest.SpyInstance = jest.spyOn(execa, "sync").mockReturnValue({
stdout: null,
stderr: undefined,
failed: false,
});

// Act...
const { failed } = processManager.trigger("ark-core", "module.name", "params");

// Assert...
expect(failed).toBeFalse();
expect(spySync).toHaveBeenCalledWith("pm2 trigger ark-core module.name params", { shell: true });
});
});

describe("#status", () => {
it("should return the status if the process exists", () => {
// Arrange...
Expand Down
8 changes: 8 additions & 0 deletions packages/core-cli/src/services/process-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@ export class ProcessManager {
return this.shellSync("pm2 update");
}

/**
* @returns {ExecaSyncReturnValue}
* @memberof ProcessManager
*/
public trigger(id: ProcessIdentifier, processActionName: string, param?: string): ExecaSyncReturnValue {
return this.shellSync(`pm2 trigger ${id} ${processActionName} ${param}`);
}

/**
* @param {ProcessIdentifier} id
* @returns {(ProcessState | undefined)}
Expand Down

0 comments on commit cf8a401

Please sign in to comment.