New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

node-persistent-software

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-persistent-software

Spawn a software and keep it running

Source
npmnpm
Version
1.3.0
Version published
Weekly downloads
2
-88.24%
Maintainers
1
Weekly downloads
 
Created
Source

node-persistent-software

Spawn a software and keep it running

Build Status Coverage Status Dependency Status

Installation

$ npm install node-persistent-software

Doc (extends : asynchronous-eventemitter)

Attributes

  • string software path to the software
  • array arguments arguments passed to the software
  • object options options passed to the software
  • object currentChildProcess current child_process
  • boolean ended if ended, don't restart it
  • int maxCountRun max start iteration
  • int successCountRun current success start iteration
  • asynchronous-eventemitter eventEmitter async events manager

Constructor

  • constructor(string software [, array arguments [, object options ] ] ) => see spawn documentation

Methods

  • max(int maxIteration) : this change max iterations and reset current
  • infinite() : this no max iteration and reset current
  • start() : this run the software for the first time
  • end() : this stop the software and don't restart it

Events

  • on("error", (string err) => {}) : this fire if an error occurs (use try/catch to avoid loop)

  • on("firststart", () => {}) : this fire if the software starts for the first time

  • on("restart", () => {}) : this fire if the software restarts

  • on("start", (object child_process) => {}) : this fire if the software starts (firststart && restart) => see spawn documentation

  • on("stop", () => {}) : this fire if the software is killed

  • on("end", () => {}) : this fire if the software is killed and cannot be restarted

Examples

const PersistantSoftware = require('node-persistent-software');

new PersistantSoftware(
  "C:\\Program Files\\Mozilla Firefox\\firefox.exe",
  [ "https://www.npmjs.com/package/node-persistent-software" ]
).on("error", (msg) => {
  console.log(msg);
})

.infinite()

.on("firststart", () => {
  console.log("Firefox is started for the first time !");
}).on("restart", () => {
  console.log("Firefox is started again...");
}).on("start", (child_process) => {
  console.log("anyway, Firefox is started.");
})

.on("stop", () => {
  console.log("Firefox is stopped, trying to restart...");
}).on("end", () => {
  console.log("/!\\ Firefox is stopped and cannot be restarted /!\\");
}).start();


new PersistantSoftware(
  "C:\\Program Files\\Mozilla Firefox\\firefox.exe",
  [ "https://github.com/Psychopoulet/node-persistent-software" ]
).on("error", (msg) {
  console.log(msg);
})

.max(5)

.on("firststart", () => {
  console.log("Firefox is started for the first time !");
}).on("restart", () => {
  console.log("Firefox is started again...");
}).on("start", () => {
  console.log("anyway, Firefox is started.");
})

.on("stop", () => {
  console.log("Firefox is stopped, trying to restart...");
}).on("end", () => {
  console.log("/!\\ Firefox is stopped and cannot be restarted /!\\");
}).start();

Tests

$ gulp

License

ISC

Keywords

spawn

FAQs

Package last updated on 09 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts