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 - npm Package Compare versions

Comparing version
1.5.0
to
1.5.1
+296
.eslintrc.js
module.exports = {
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2018
},
"env": {
"es6": true,
"mocha": true,
"node": true
},
"globals": {
"after": true,
"afterEach": true,
"angular": true,
"before": true,
"beforeEach": true,
"Buffer": true,
"console": true,
"clearInterval": true,
"clearTimeout": true,
"describe": true,
"it": true,
"jQuery": true,
"Promise": true,
"Map": true,
"module": true,
"os": true,
"process": true,
"require": true,
"setImmediate": true,
"setInterval": true,
"setTimeout": true,
"__dirname": true,
"__filename": true
},
"rules": {
"for-direction": "error",
"getter-return": "error",
"no-await-in-loop": "error",
"no-compare-neg-zero": "error",
"no-cond-assign": "error",
"no-console": "error",
"no-constant-condition": "error",
"no-control-regex": "error",
"no-debugger": "error",
"no-dupe-args": "error",
"no-dupe-keys": "error",
"no-duplicate-case": "error",
"no-empty": "error",
"no-empty-character-class": "error",
"no-ex-assign": "error",
"no-extra-boolean-cast": "error",
"no-extra-parens": "error",
"no-extra-semi": "error",
"no-func-assign": "error",
"no-inner-declarations": "error",
"no-invalid-regexp": "error",
"no-irregular-whitespace": "error",
"no-obj-calls": "error",
"no-prototype-builtins": "error",
"no-regex-spaces": "error",
"no-sparse-arrays": "error",
"no-template-curly-in-string": "error",
"no-unexpected-multiline": "error",
"no-unreachable": "error",
"no-unsafe-finally": "error",
"no-unsafe-negation": "error",
"use-isnan": "error",
"valid-jsdoc": "error",
"valid-typeof": "error",
"accessor-pairs": "error",
"array-callback-return": "error",
"block-scoped-var": "error",
"class-methods-use-this": "error",
"complexity": "error",
"consistent-return": "error",
"curly": "error",
"default-case": "error",
"dot-location": [ "error", "property" ],
"dot-notation": "error",
"eqeqeq": "error",
"guard-for-in": "error",
"no-alert": "error",
"no-caller": "error",
"no-case-declarations": "error",
"no-div-regex": "error",
"no-else-return": 0,
"no-empty-function": "error",
"no-empty-pattern": "error",
"no-eq-null": "error",
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-extra-label": "error",
"no-fallthrough": "error",
"no-floating-decimal": "error",
"no-global-assign": "error",
"no-implicit-coercion": "error",
"no-implicit-globals": "error",
"no-implied-eval": "error",
"no-invalid-this": "error",
"no-iterator": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-loop-func": "error",
"no-magic-numbers": 0,
"no-multi-spaces": "error",
"no-multi-str": "error",
"no-new": "error",
"no-new-func": "error",
"no-new-wrappers": "error",
"no-octal": "error",
"no-octal-escape": "error",
"no-param-reassign": "error",
"no-proto": "error",
"no-redeclare": "error",
"no-restricted-properties": "error",
"no-return-assign": "error",
"no-return-await": "error",
"no-script-url": "error",
"no-self-assign": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-throw-literal": "error",
"no-unmodified-loop-condition": "error",
"no-unused-expressions": "error",
"no-unused-labels": "error",
"no-useless-call": "error",
"no-useless-concat": "error",
"no-useless-escape": "error",
"no-useless-return": "error",
"no-void": "error",
"no-warning-comments": "error",
"no-with": "error",
"prefer-promise-reject-errors": "error",
"radix": "error",
"require-await": "error",
"vars-on-top": "error",
"wrap-iife": "error",
"yoda": [ "error", "always" ],
"strict": [ "error", "global" ],
"init-declarations": "error",
"no-catch-shadow": "error",
"no-delete-var": "error",
"no-label-var": "error",
"no-restricted-globals": "error",
"no-shadow": "error",
"no-shadow-restricted-names": "error",
"no-undef": "error",
"no-undef-init": "error",
"no-undefined": "error",
"no-unused-vars": "error",
"no-use-before-define": "error",
"callback-return": "error",
"global-require": 0,
"handle-callback-err": "error",
"no-buffer-constructor": "error",
"no-mixed-requires": "error",
"no-new-require": "error",
"no-path-concat": "error",
"no-process-env": "error",
"no-process-exit": "error",
"no-restricted-modules": "error",
"no-sync": "error",
"array-bracket-newline": "error",
"array-bracket-spacing": [ "error", "always" ],
"array-element-newline": [ "error", "consistent" ],
"block-spacing": "error",
"brace-style": [ "error", "stroustrup" ],
"camelcase": "error",
"capitalized-comments": 0,
"comma-dangle": [ "error", "never" ],
"comma-spacing": [ "error", { "before": false, "after": true } ],
"comma-style": [ "error", "last" ],
"computed-property-spacing": [ "error", "never" ],
"consistent-this": "error",
"eol-last": "error",
"func-call-spacing": "error",
"func-name-matching": "error",
"func-names": "error",
"func-style": [ "error", "declaration" ],
"id-blacklist": 0,
"id-length": 0,
"id-match": 0,
"indent": 0,
"jsx-quotes": [ "error", "prefer-double" ],
"key-spacing": [ "error", { "beforeColon": false, "afterColon": true } ],
"keyword-spacing": [ "error", { "after": true, "before": true } ],
"line-comment-position": [ "error", { "position": "above" } ],
"linebreak-style": 0,
"lines-around-comment": "error",
"max-depth": [ "error", 4 ],
"max-len": [ "error", 150 ],
"max-lines": [ "error", { "max": 500, "skipComments": true } ],
"max-nested-callbacks": [ "error", 5 ],
"max-params": [ "error", 4 ],
"max-statements": [ "error", 25 ],
"max-statements-per-line": [ "error", { "max": 2 } ],
"multiline-ternary": 0,
"new-cap": "error",
"new-parens": "error",
"newline-per-chained-call": 0,
"no-array-constructor": "error",
"no-bitwise": "error",
"no-continue": "error",
"no-inline-comments": "error",
"no-lonely-if": "error",
"no-mixed-operators": "error",
"no-mixed-spaces-and-tabs": "error",
"no-multi-assign": "error",
"no-multiple-empty-lines": "error",
"no-negated-condition": 0,
"no-nested-ternary": "error",
"no-new-object": "error",
"no-plusplus": 0,
"no-restricted-syntax": "error",
"no-tabs": [ "error", { "allowIndentationTabs": true } ],
"no-ternary": 0,
"no-trailing-spaces": "error",
"no-underscore-dangle": 0,
"no-unneeded-ternary": "error",
"no-whitespace-before-property": "error",
"nonblock-statement-body-position": [ "error", "below" ],
"object-curly-newline": [ "error", { "consistent": true } ],
"object-curly-spacing": [ "error", "always" ],
"object-property-newline": "error",
"one-var": [ "error", "never" ],
"one-var-declaration-per-line": "error",
"operator-assignment": [ "error", "always" ],
"operator-linebreak": [ "error", "after" ],
"padded-blocks": ["error", { "classes": "always", "switches": "always" } ],
"padding-line-between-statements": "error",
"quote-props": [ "error", "always" ],
"quotes": [ "error", "double" ],
"require-jsdoc": "error",
"semi": [ "error", "always" ],
"semi-spacing": [ "error", { "before": false, "after": true } ],
"semi-style": [ "error", "last" ],
"sort-keys": 0,
"sort-vars": "error",
"space-before-blocks": [ "error", "always" ],
"space-before-function-paren": [ "error", "always" ],
"space-in-parens": [ "error", "never" ],
"space-infix-ops": "error",
"space-unary-ops": "error",
"spaced-comment": [ "error", "always" ],
"switch-colon-spacing": [ "error", { "after": true, "before": false } ],
"template-tag-spacing": [ "error", "always" ],
"unicode-bom": 0,
"wrap-regex": "error",
"arrow-body-style": [ "error", "always" ],
"arrow-parens": [ "error", "always" ],
"arrow-spacing": ["error", { "before": true, "after": true } ],
"constructor-super": "error",
"generator-star-spacing": [ "error", { "before": true, "after": false } ],
"no-class-assign": "error",
"no-confusing-arrow": "error",
"no-const-assign": "error",
"no-dupe-class-members": "error",
"no-duplicate-imports": "error",
"no-new-symbol": "error",
"no-restricted-imports": 0,
"no-this-before-super": "error",
"no-useless-computed-key": "error",
"no-useless-constructor": "error",
"no-useless-rename": "error",
"no-var": "error",
"object-shorthand": "error",
"prefer-arrow-callback": "error",
"prefer-const": "error",
"prefer-destructuring": "error",
"prefer-numeric-literals": "error",
"prefer-rest-params": "error",
"prefer-spread": "error",
"prefer-template": 0,
"require-yield": "error",
"rest-spread-spacing": [ "error", "never" ],
"sort-imports": "error",
"symbol-description": "error",
"template-curly-spacing": "error",
"yield-star-spacing": [ "error", { "before": true, "after": false } ]
}
};
"use strict";
// deps
const { exec } = require("child_process");
const { join } = require("path");
const { unlink } = require("fs");
// consts
const MAX_TIMEOUT = 10000;
// tests
describe("compilation typescript", () => {
after((done) => {
unlink(join(__dirname, "typescript", "compilation.js"), (err) => {
return err ? done(err) : done();
});
});
it("should compile typescript file", (done) => {
exec("tsc " + join(__dirname, "typescript", "compilation.ts"), {
"cwd": join(__dirname, ".."),
"windowsHide": true
}, (err) => {
return err ? done(err) : done();
});
}).timeout(MAX_TIMEOUT);
});
"use strict";
// deps
const assert = require("assert");
const PersistantSoftware = require(require("path").join(__dirname, "..", "lib", "main.js"));
// consts
const IPCONFIG = "win32" === require("os").platform() ? "ipconfig" : "ifconfig";
const MAX_TIMEOUT = 10000;
// tests
describe("run", () => {
it("should check wrong path running", () => {
return new Promise((resolve, reject) => {
// there IS an error. this is the point.
const ps = new PersistantSoftware("wsdvwsdvwsdvwsdvsdv").on("error", () => {
// nothing to do here
});
ps.on("firststart", () => {
reject(new Error("software found"));
}).on("end", () => {
assert.strictEqual(0, ps.successCountRun, "wrong count");
assert.strictEqual(1, ps.maxCountRun, "wrong max");
resolve();
}).max(1).start();
});
}).timeout(MAX_TIMEOUT);
it("should check no args running", () => {
return new Promise((resolve, reject) => {
const ps = new PersistantSoftware("node").on("error", reject);
ps.on("firststart", () => {
setTimeout(() => {
ps.end();
}, 200);
}).on("restart", () => {
reject(new Error("restarted"));
}).on("end", () => {
assert.strictEqual(1, ps.successCountRun, "wrong count");
assert.strictEqual(1, ps.maxCountRun, "wrong max");
resolve();
}).max(1).start();
});
}).timeout(MAX_TIMEOUT);
it("should check normal running with max", () => {
return new Promise((resolve, reject) => {
let version = "";
const ps = new PersistantSoftware("node", [ "-v" ]).on("error", reject);
ps.on("start", (process) => {
process.stdout.on("data", (data) => {
version = data.toString("utf8").trim();
});
}).on("end", () => {
assert.strictEqual(process.version, version, "wrong version");
assert.strictEqual(2, ps.successCountRun, "wrong count");
assert.strictEqual(2, ps.maxCountRun, "wrong max");
resolve();
}).max(2).start();
});
}).timeout(MAX_TIMEOUT);
it("should check normal running with infinite and end", () => {
return new Promise((resolve, reject) => {
const ps = new PersistantSoftware("node", [ "-v" ], {
"cwd": __dirname
}).on("error", reject);
ps.on("restart", () => {
ps.end();
}).on("end", () => {
assert.strictEqual(2, ps.successCountRun, "wrong count");
assert.strictEqual(0, ps.maxCountRun, "wrong max");
resolve();
}).infinite().start();
});
}).timeout(MAX_TIMEOUT);
it("should check normal running with infinite and end", () => {
return new Promise((resolve, reject) => {
let firstStarted = false;
let restarted = false;
let started = false;
const ps = new PersistantSoftware(IPCONFIG).on("error", reject).infinite()
.on("firststart", () => {
firstStarted = true;
}).on("restart", () => {
restarted = true;
}).on("start", () => {
started = true;
})
.on("stop", () => {
if (2 <= ps.successCountRun) {
ps.end();
}
}).on("end", () => {
assert.strictEqual(firstStarted, true, "not started for the first time");
assert.strictEqual(restarted, true, "not restarted");
assert.strictEqual(started, true, "not started at all");
resolve();
}).start();
});
}).timeout(MAX_TIMEOUT);
});
/// <reference path="../../lib/index.d.ts" />
import PersistantSoftware = require("../../lib/main.js");
new PersistantSoftware("node", [ "-v" ]).on("error", (err: Error) => {
console.log(err);
})
.infinite()
.on("firststart", () => {
console.log("node is started for the first time !");
}).on("restart", () => {
console.log("node is started again...");
}).on("start", (child_process) => {
console.log("anyway, node is started.");
})
.on("stop", () => {
console.log("node is stopped, trying to restart...");
}).on("end", () => {
console.log("/!\\ node is stopped and cannot be restarted /!\\");
}).start();
new PersistantSoftware("node", [ "-v" ]).on("error", (err: Error) => {
console.log(err);
})
.max(5)
.on("firststart", () => {
console.log("node is started for the first time !");
}).on("restart", () => {
console.log("node is started again...");
}).on("start", () => {
console.log("anyway, node is started.");
})
.on("stop", () => {
console.log("node is stopped, trying to restart...");
}).on("end", () => {
console.log("/!\\ node is stopped and cannot be restarted /!\\");
}).start();
+2
-2
language: node_js
node_js:
- "6"
- "8"
- "10"
install:
- "npm install -g typescript"
- "npm install"
script: "npm run-script tests"
script: "npm run-script ci"

@@ -1,2 +0,2 @@

Copyright (c) 2018, Sébastien Vidal
Copyright (c) 2019, Sébastien Vidal

@@ -3,0 +3,0 @@ Permission to use, copy, modify, and/or distribute this software for any

{
"name": "node-persistent-software",
"version": "1.5.0",
"version": "1.5.1",
"description": "Spawn a software and keep it running",

@@ -8,7 +8,14 @@ "main": "lib/main.js",

"scripts": {
"tests": "gulp tests"
"lint": "npx eslint ./lib/**/*.js ./test/**/*.js",
"check-updates": "npx check-version-modules",
"unit-tests": "npx nyc --reporter=html --reporter=text mocha",
"tests": "npm run-script lint && npm run-script check-updates && npm run-script unit-tests",
"ci": "npm run-script tests && npx nyc report --reporter=text-lcov | coveralls"
},
"pre-push": [
"tests"
],
"husky": {
"hooks": {
"pre-commit": "npm run-script lint",
"pre-push": "npm run-script tests"
}
},
"repository": {

@@ -32,13 +39,12 @@ "type": "git",

"dependencies": {
"asynchronous-eventemitter": "0.3.3"
"asynchronous-eventemitter": "0.3.6"
},
"devDependencies": {
"@types/node": "9.6.7",
"gulp": "4.0.0",
"gulp-coveralls": "0.1.4",
"gulp-eslint": "4.0.2",
"gulp-istanbul": "1.1.3",
"gulp-mocha": "3.0.1",
"gulp-plumber": "1.2.0",
"pre-push": "0.1.1"
"@types/node": "10.12.18",
"check-version-modules": "1.1.1",
"coveralls": "3.0.2",
"eslint": "5.12.0",
"mocha": "5.2.0",
"nyc": "13.1.0",
"husky": "1.3.1"
},

@@ -45,0 +51,0 @@ "homepage": "https://github.com/Psychopoulet/node-persistent-software#readme",

# node-persistent-software
Spawn a software and keep it running
[![Build Status](https://api.travis-ci.org/Psychopoulet/node-persistent-software.svg?branch=master)](https://travis-ci.org/Psychopoulet/node-persistent-software)
[![Coverage Status](https://coveralls.io/repos/github/Psychopoulet/node-persistent-software/badge.svg?branch=master)](https://coveralls.io/github/Psychopoulet/node-persistent-software)
[![Dependency Status](https://david-dm.org/Psychopoulet/node-persistent-software/status.svg)](https://david-dm.org/Psychopoulet/node-persistent-software)
[![Dev dependency Status](https://david-dm.org/Psychopoulet/node-persistent-software/dev-status.svg)](https://david-dm.org/Psychopoulet/node-persistent-software?type=dev)
[![Build status](https://api.travis-ci.org/Psychopoulet/node-persistent-software.svg?branch=master)](https://travis-ci.org/Psychopoulet/node-persistent-software)
[![Coverage status](https://coveralls.io/repos/github/Psychopoulet/node-persistent-software/badge.svg?branch=master)](https://coveralls.io/github/Psychopoulet/node-persistent-software)
[![Dependency status](https://david-dm.org/Psychopoulet/node-persistent-software/status.svg)](https://david-dm.org/Psychopoulet/node-persistent-software)
[![Dev dependency status](https://david-dm.org/Psychopoulet/node-persistent-software/dev-status.svg)](https://david-dm.org/Psychopoulet/node-persistent-software?type=dev)
[![Issues](https://img.shields.io/github/issues/Psychopoulet/node-persistent-software.svg)](https://github.com/Psychopoulet/node-persistent-software/issues)
[![Pull requests](https://img.shields.io/github/issues-pr/Psychopoulet/node-persistent-software.svg)](https://github.com/Psychopoulet/node-persistent-software/pulls)

@@ -108,3 +110,3 @@ ## Installation

```bash
$ gulp
$ npm run-script tests
```

@@ -111,0 +113,0 @@

"use strict";
// deps
const path = require("path");
// gulp
const gulp = require("gulp");
const plumber = require("gulp-plumber");
// tests
const eslint = require("gulp-eslint");
const mocha = require("gulp-mocha");
// reports
const istanbul = require("gulp-istanbul");
const coveralls = require("gulp-coveralls");
// consts
const ISTRAVIS = (0, process).env.TRAVIS || false;
const APP_FILES = [ path.join(__dirname, "lib", "**", "*.js") ];
const UNITTESTS_FILES = [ path.join(__dirname, "tests", "**", "*.js") ];
const ALL_FILES = [ path.join(__dirname, "gulpfile.js") ]
.concat(APP_FILES)
.concat(UNITTESTS_FILES);
// tasks
gulp.task("eslint", () => {
return gulp.src(ALL_FILES)
.pipe(plumber())
.pipe(eslint({
"env": require(path.join(__dirname, "gulpfile", "eslint", "env.json")),
"globals": require(path.join(__dirname, "gulpfile", "eslint", "globals.json")),
"parserOptions": {
"ecmaVersion": 6
},
// http://eslint.org/docs/rules/
"rules": require(path.join(__dirname, "gulpfile", "eslint", "rules.json"))
}))
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task("istanbul", gulp.series("eslint", () => {
return gulp.src(APP_FILES)
.pipe(plumber())
.pipe(istanbul({ "includeUntested": true }))
.pipe(istanbul.hookRequire());
}));
gulp.task("mocha", gulp.series("istanbul", () => {
return gulp.src(UNITTESTS_FILES)
.pipe(plumber())
.pipe(mocha())
.pipe(istanbul.writeReports())
.pipe(istanbul.enforceThresholds({ "thresholds": { "global": 85 } }));
}));
gulp.task("coveralls", gulp.series("mocha", () => {
return gulp.src(path.join(__dirname, "coverage", "lcov.info"))
.pipe(plumber())
.pipe(coveralls());
}));
gulp.task("tests", gulp.series(ISTRAVIS ? "coveralls" : "mocha"));
// watcher
gulp.task("watch", () => {
gulp.watch(ALL_FILES, [ "eslint" ]);
});
// default
gulp.task("default", gulp.series("mocha"));
{
"es6": true,
"mocha": true,
"node": true
}
[
"after",
"afterEach",
"angular",
"before",
"beforeEach",
"Buffer",
"console",
"clearInterval",
"clearTimeout",
"describe",
"it",
"jQuery",
"Promise",
"Map",
"module",
"os",
"process",
"require",
"setImmediate",
"setInterval",
"setTimeout",
"__dirname",
"__filename"
]
{
"for-direction": 0,
"getter-return": "error",
"no-await-in-loop": "error",
"no-compare-neg-zero": "error",
"no-cond-assign": "error",
"no-console": [ "error", { "allow": [ "info", "warn", "error" ] }],
"no-constant-condition": "error",
"no-control-regex": "error",
"no-debugger": "error",
"no-dupe-args": "error",
"no-dupe-keys": "error",
"no-duplicate-case": "error",
"no-empty": "error",
"no-empty-character-class": "error",
"no-ex-assign": "error",
"no-extra-boolean-cast": "error",
"no-extra-parens": "error",
"no-extra-semi": "error",
"no-func-assign": "error",
"no-inner-declarations": "error",
"no-invalid-regexp": "error",
"no-irregular-whitespace": "error",
"no-obj-calls": "error",
"no-prototype-builtins": "error",
"no-regex-spaces": "error",
"no-sparse-arrays": "error",
"no-template-curly-in-string": "error",
"no-unexpected-multiline": "error",
"no-unreachable": "error",
"no-unsafe-finally": "error",
"no-unsafe-negation": "error",
"use-isnan": "error",
"valid-jsdoc": "error",
"valid-typeof": "error",
"accessor-pairs": "error",
"array-callback-return": "error",
"block-scoped-var": "error",
"class-methods-use-this": "error",
"complexity": "error",
"consistent-return": "error",
"curly": "error",
"default-case": "error",
"dot-location": [ "error", "property" ],
"dot-notation": "error",
"eqeqeq": "error",
"guard-for-in": "error",
"no-alert": "error",
"no-caller": "error",
"no-case-declarations": "error",
"no-div-regex": "error",
"no-else-return": 0,
"no-empty-function": "error",
"no-empty-pattern": "error",
"no-eq-null": "error",
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-extra-label": "error",
"no-fallthrough": "error",
"no-floating-decimal": "error",
"no-global-assign": "error",
"no-implicit-coercion": "error",
"no-implicit-globals": "error",
"no-implied-eval": "error",
"no-invalid-this": "error",
"no-iterator": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-loop-func": "error",
"no-magic-numbers": 0,
"no-multi-spaces": "error",
"no-multi-str": "error",
"no-new": "error",
"no-new-func": "error",
"no-new-wrappers": "error",
"no-octal": "error",
"no-octal-escape": "error",
"no-param-reassign": "error",
"no-proto": "error",
"no-redeclare": "error",
"no-restricted-properties": "error",
"no-return-assign": "error",
"no-return-await": "error",
"no-script-url": "error",
"no-self-assign": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-throw-literal": "error",
"no-unmodified-loop-condition": "error",
"no-unused-expressions": "error",
"no-unused-labels": "error",
"no-useless-call": "error",
"no-useless-concat": "error",
"no-useless-escape": "error",
"no-useless-return": "error",
"no-void": "error",
"no-warning-comments": "error",
"no-with": "error",
"prefer-promise-reject-errors": "error",
"radix": "error",
"require-await": "error",
"vars-on-top": "error",
"wrap-iife": "error",
"yoda": [ "error", "always" ],
"strict": [ "error", "global" ],
"init-declarations": [ "error", "always" ],
"no-catch-shadow": "error",
"no-delete-var": 0,
"no-label-var": "error",
"no-restricted-globals": "error",
"no-shadow": "error",
"no-shadow-restricted-names": "error",
"no-undef": "error",
"no-undef-init": "error",
"no-undefined": "error",
"no-unused-vars": "error",
"no-use-before-define": "error",
"callback-return": [ "error", [ "done", "send.error", "send.success" ] ],
"global-require": 0,
"handle-callback-err": "error",
"no-buffer-constructor": "error",
"no-mixed-requires": "error",
"no-new-require": "error",
"no-path-concat": "error",
"no-process-env": "error",
"no-process-exit": "error",
"no-restricted-modules": "error",
"no-sync": "error",
"array-bracket-newline": [ "error", { "multiline": true } ],
"array-bracket-spacing": [ "error", "always" ],
"array-element-newline": 0,
"block-spacing": "error",
"brace-style": [ "error", "stroustrup" ],
"camelcase": "error",
"capitalized-comments": 0,
"comma-dangle": [ "error", "never" ],
"comma-spacing": [ "error", { "before": false, "after": true } ],
"comma-style": [ "error", "last" ],
"computed-property-spacing": [ "error", "never" ],
"consistent-this": "error",
"eol-last": "error",
"func-call-spacing": "error",
"func-name-matching": "error",
"func-names": [ "error", "always" ],
"func-style": [ "error", "declaration" ],
"id-blacklist": 0,
"id-length": 0,
"id-match": 0,
"indent": 0,
"jsx-quotes": [ "error", "prefer-double" ],
"key-spacing": [ "error", { "beforeColon": false, "afterColon": true } ],
"keyword-spacing": [ "error", { "after": true, "before": true } ],
"line-comment-position": [ "error", { "position": "above" } ],
"linebreak-style": 0,
"lines-around-comment": "error",
"max-depth": 0,
"max-len": [ "error", 150 ],
"max-lines": 0,
"max-nested-callbacks": [ "error", 5 ],
"max-params": [ "error", 5 ],
"max-statements": 0,
"max-statements-per-line": [ "error", { "max": 2 } ],
"multiline-ternary": 0,
"new-cap": "error",
"new-parens": "error",
"newline-per-chained-call": 0,
"no-array-constructor": "error",
"no-bitwise": "error",
"no-continue": "error",
"no-inline-comments": "error",
"no-lonely-if": "error",
"no-mixed-operators": "error",
"no-mixed-spaces-and-tabs": "error",
"no-multi-assign": "error",
"no-multiple-empty-lines": "error",
"no-negated-condition": 0,
"no-nested-ternary": "error",
"no-new-object": "error",
"no-plusplus": 0,
"no-restricted-syntax": "error",
"no-tabs": 0,
"no-ternary": 0,
"no-trailing-spaces": "error",
"no-underscore-dangle": 0,
"no-unneeded-ternary": "error",
"no-whitespace-before-property": "error",
"nonblock-statement-body-position": [ "error", "below" ],
"object-curly-newline": [ "error", { "consistent": true } ],
"object-curly-spacing": [ "error", "always" ],
"object-property-newline": "error",
"one-var": [ "error", "never" ],
"one-var-declaration-per-line": "error",
"operator-assignment": [ "error", "always" ],
"operator-linebreak": [ "error", "after" ],
"padded-blocks": ["error", { "classes": "always", "switches": "always" } ],
"padding-line-between-statements": "error",
"quote-props": [ "error", "always" ],
"quotes": [ "error", "double" ],
"require-jsdoc": "error",
"semi": [ "error", "always" ],
"semi-spacing": [ "error", { "before": false, "after": true } ],
"semi-style": [ "error", "last" ],
"sort-keys": 0,
"sort-vars": "error",
"space-before-blocks": [ "error", "always" ],
"space-before-function-paren": [ "error", "always" ],
"space-in-parens": [ "error", "never" ],
"space-infix-ops": "error",
"space-unary-ops": "error",
"spaced-comment": [ "error", "always" ],
"switch-colon-spacing": [ "error", { "after": true, "before": false } ],
"template-tag-spacing": [ "error", "always" ],
"unicode-bom": 0,
"wrap-regex": "error",
"arrow-body-style": [ "error", "always" ],
"arrow-parens": [ "error", "always" ],
"arrow-spacing": ["error", { "before": true, "after": true } ],
"constructor-super": "error",
"generator-star-spacing": [ "error", { "before": true, "after": false } ],
"no-class-assign": "error",
"no-confusing-arrow": "error",
"no-const-assign": "error",
"no-dupe-class-members": "error",
"no-duplicate-imports": "error",
"no-new-symbol": "error",
"no-restricted-imports": 0,
"no-this-before-super": "error",
"no-useless-computed-key": "error",
"no-useless-constructor": "error",
"no-useless-rename": "error",
"no-var": "error",
"object-shorthand": "error",
"prefer-arrow-callback": "error",
"prefer-const": "error",
"prefer-destructuring": "error",
"prefer-numeric-literals": "error",
"prefer-rest-params": "error",
"prefer-spread": "error",
"prefer-template": 0,
"require-yield": "error",
"rest-spread-spacing": [ "error", "never" ],
"sort-imports": "error",
"symbol-description": "error",
"template-curly-spacing": "error",
"yield-star-spacing": [ "error", { "before": true, "after": false } ]
}
"use strict";
// deps
const { exec } = require("child_process");
const { join } = require("path");
const { unlink } = require("fs");
// consts
const MAX_TIMEOUT = 10000;
// tests
describe("compilation typescript", () => {
after((done) => {
unlink(join(__dirname, "typescript", "compilation.js"), (err) => {
return err ? done(err) : done();
});
});
it("should compile typescript file", (done) => {
exec("tsc " + join(__dirname, "typescript", "compilation.ts"), {
"cwd": join(__dirname, ".."),
"windowsHide": true
}, (err) => {
return err ? done(err) : done();
});
}).timeout(MAX_TIMEOUT);
});
"use strict";
// deps
const assert = require("assert");
const PersistantSoftware = require(require("path").join(__dirname, "..", "lib", "main.js"));
// consts
const IPCONFIG = "win32" === require("os").platform() ? "ipconfig" : "ifconfig";
const MAX_TIMEOUT = 10000;
// tests
describe("run", () => {
it("should check wrong path running", () => {
return new Promise((resolve, reject) => {
// there IS an error. this is the point.
const ps = new PersistantSoftware("wsdvwsdvwsdvwsdvsdv").on("error", () => {
// nothing to do here
});
ps.on("firststart", () => {
reject(new Error("software found"));
}).on("end", () => {
assert.strictEqual(0, ps.successCountRun, "wrong count");
assert.strictEqual(1, ps.maxCountRun, "wrong max");
resolve();
}).max(1).start();
});
}).timeout(MAX_TIMEOUT);
it("should check no args running", () => {
return new Promise((resolve, reject) => {
const ps = new PersistantSoftware("node").on("error", reject);
ps.on("firststart", () => {
setTimeout(() => {
ps.end();
}, 200);
}).on("restart", () => {
reject(new Error("restarted"));
}).on("end", () => {
assert.strictEqual(1, ps.successCountRun, "wrong count");
assert.strictEqual(1, ps.maxCountRun, "wrong max");
resolve();
}).max(1).start();
});
}).timeout(MAX_TIMEOUT);
it("should check normal running with max", () => {
return new Promise((resolve, reject) => {
let version = "";
const ps = new PersistantSoftware("node", [ "-v" ]).on("error", reject);
ps.on("start", (process) => {
process.stdout.on("data", (data) => {
version = data.toString("utf8").trim();
});
}).on("end", () => {
assert.strictEqual(process.version, version, "wrong version");
assert.strictEqual(2, ps.successCountRun, "wrong count");
assert.strictEqual(2, ps.maxCountRun, "wrong max");
resolve();
}).max(2).start();
});
}).timeout(MAX_TIMEOUT);
it("should check normal running with infinite and end", () => {
return new Promise((resolve, reject) => {
const ps = new PersistantSoftware("node", [ "-v" ], {
"cwd": __dirname
}).on("error", reject);
ps.on("restart", () => {
ps.end();
}).on("end", () => {
assert.strictEqual(2, ps.successCountRun, "wrong count");
assert.strictEqual(0, ps.maxCountRun, "wrong max");
resolve();
}).infinite().start();
});
}).timeout(MAX_TIMEOUT);
it("should check normal running with infinite and end", () => {
return new Promise((resolve, reject) => {
let firstStarted = false;
let restarted = false;
let started = false;
const ps = new PersistantSoftware(IPCONFIG).on("error", reject).infinite()
.on("firststart", () => {
firstStarted = true;
}).on("restart", () => {
restarted = true;
}).on("start", () => {
started = true;
})
.on("stop", () => {
if (2 <= ps.successCountRun) {
ps.end();
}
}).on("end", () => {
assert.strictEqual(firstStarted, true, "not started for the first time");
assert.strictEqual(restarted, true, "not restarted");
assert.strictEqual(started, true, "not started at all");
resolve();
}).start();
});
}).timeout(MAX_TIMEOUT);
});
/// <reference path="../../lib/index.d.ts" />
import PersistantSoftware = require("../../lib/main.js");
new PersistantSoftware("node", [ "-v" ]).on("error", (err: Error) => {
console.log(err);
})
.infinite()
.on("firststart", () => {
console.log("node is started for the first time !");
}).on("restart", () => {
console.log("node is started again...");
}).on("start", (child_process) => {
console.log("anyway, node is started.");
})
.on("stop", () => {
console.log("node is stopped, trying to restart...");
}).on("end", () => {
console.log("/!\\ node is stopped and cannot be restarted /!\\");
}).start();
new PersistantSoftware("node", [ "-v" ]).on("error", (err: Error) => {
console.log(err);
})
.max(5)
.on("firststart", () => {
console.log("node is started for the first time !");
}).on("restart", () => {
console.log("node is started again...");
}).on("start", () => {
console.log("anyway, node is started.");
})
.on("stop", () => {
console.log("node is stopped, trying to restart...");
}).on("end", () => {
console.log("/!\\ node is stopped and cannot be restarted /!\\");
}).start();