Skip to content

Commit

Permalink
Make some maintenance (#76)
Browse files Browse the repository at this point in the history
- Update dependencies
- Reapply eslint
- Fix promise type in test
- Update copyright date
  • Loading branch information
chapterjason authored Feb 4, 2021
1 parent cbaa6b8 commit c927e53
Show file tree
Hide file tree
Showing 21 changed files with 1,818 additions and 2,242 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2020 media-service consulting & solutions GmbH
Copyright (c) 2021 media-service consulting & solutions GmbH
Copyright (c) 2004-2020 Fabien Potencier

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
2 changes: 1 addition & 1 deletion __tests__/Input/InputStream.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of the @mscs/process package.
*
* Copyright (c) 2020 media-service consulting & solutions GmbH
* Copyright (c) 2021 media-service consulting & solutions GmbH
*
* For the full copyright and license information, please view the LICENSE
* File that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion __tests__/Input/Mock/OutputMock.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of the @mscs/process package.
*
* Copyright (c) 2020 media-service consulting & solutions GmbH
* Copyright (c) 2021 media-service consulting & solutions GmbH
*
* For the full copyright and license information, please view the LICENSE
* File that was distributed with this source code.
Expand Down
8 changes: 5 additions & 3 deletions __tests__/Output/OutputStream.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of the @mscs/process package.
*
* Copyright (c) 2020 media-service consulting & solutions GmbH
* Copyright (c) 2021 media-service consulting & solutions GmbH
*
* For the full copyright and license information, please view the LICENSE
* File that was distributed with this source code.
Expand All @@ -27,7 +27,8 @@ describe("OutputStream", () => {
output.on("finish", () => {
expect(output.toString()).toEqual("foo");
expect(output.toBuffer().toString()).toEqual("foo");
resolve();

resolve(null);
});
}));
});
Expand All @@ -47,7 +48,8 @@ describe("OutputStream", () => {
output.on("finish", () => {
expect(output.toString()).toEqual("foobar");
expect(output.toBuffer().toString()).toEqual("foobar");
resolve();

resolve(null);
});
}));
});
Expand Down
7 changes: 6 additions & 1 deletion __tests__/Process/Process.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/*
* This file is part of the @mscs/process package.
*
* Copyright (c) 2020 media-service consulting & solutions GmbH
* Copyright (c) 2021 media-service consulting & solutions GmbH
*
* For the full copyright and license information, please view the LICENSE
* File that was distributed with this source code.
*/

import * as path from "path";

import { LogicException } from "../../src/Exception/LogicException";
import { ProcessFailedException } from "../../src/Exception/ProcessFailedException";
import { RuntimeException } from "../../src/Exception/RuntimeException";
Expand Down Expand Up @@ -259,6 +260,7 @@ describe("Process", () => {
it("should pipe continuously", async () => {
// Arrange
const runningProcess = new Process(["node", path.join(__dirname, "test-process.js")]);

await runningProcess.start();
const output = new OutputStream();
const stdout = runningProcess.getStdout();
Expand Down Expand Up @@ -293,6 +295,7 @@ describe("Process", () => {

for (const message of messages) {
const difference = message.output.timestamp - message.timestamp;

expect(difference).toBeLessThan(50);
expect(difference).toBeGreaterThan(-50);
}
Expand All @@ -305,6 +308,7 @@ describe("Process", () => {
it("should kill the underlying process", async () => {
// Arrange
const runningProcess = new Process(["node", path.join(__dirname, "test-process.js")]);

await runningProcess.start();
const output = new OutputStream();
const stdout = runningProcess.getStdout();
Expand Down Expand Up @@ -334,6 +338,7 @@ describe("Process", () => {
it("should not throw if exit code is zero", async () => {
// Arrange
const process = new Process(["node", "-e", "process.exit(0);"]);

await process.run();

// Act
Expand Down
1 change: 1 addition & 0 deletions __tests__/Process/test-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function next() {

setTimeout(function () {
const timestamp = (new Date()).getTime();

write(JSON.stringify({ index: current, timestamp }));
next();
}, interval);
Expand Down
31 changes: 14 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
"build": "webpack --config webpack.config.js --mode=production",
"build:dev": "webpack --config webpack.config.js --mode=development",
"build:watch": "webpack --config webpack.config.js --watch --mode=development",
"lint": "eslint \"./src/**/*\" \"./__tests__/**/*\"",
"lint": "eslint ./src/ ./__tests__/",
"test": "jest",
"test:watch": "jest --watchAll",
"docs": "typedoc --listInvalidSymbolLinks src/"
},
"files": [
Expand All @@ -26,22 +25,20 @@
"LICENSE"
],
"devDependencies": {
"@mscs/eslint-config": "^0.1.2",
"@types/jest": "^26.0.0",
"@types/node": "^12.12.47",
"@typescript-eslint/eslint-plugin": "^3.2.0",
"@mscs/eslint-config": "^0.2.1",
"@tsconfig/node12": "^1.0.7",
"@types/jest": "^26.0.20",
"@types/node": "^12.19.16",
"clean-webpack-plugin": "^3.0.0",
"eslint": "^7.2.0",
"eslint-plugin-simple-import-sort": "^5.0.3",
"jest": "^26.0.1",
"jest-each": "^26.0.1",
"eslint": "^7.19.0",
"jest": "^26.6.3",
"jest-each": "^26.6.2",
"stream-mock": "^2.0.5",
"ts-jest": "^26.1.0",
"ts-loader": "^7.0.5",
"typedoc": "^0.17.7",
"typescript": "^3.9.5",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11",
"webpack-node-externals": "^1.7.2"
"ts-jest": "^26.5.0",
"ts-loader": "^8.0.14",
"typedoc": "^0.20.20",
"typescript": "^4.1.3",
"webpack": "^5.20.1",
"webpack-cli": "^4.5.0"
}
}
2 changes: 1 addition & 1 deletion src/Exception/ArgumentException.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of the @mscs/process package.
*
* Copyright (c) 2020 media-service consulting & solutions GmbH
* Copyright (c) 2021 media-service consulting & solutions GmbH
*
* For the full copyright and license information, please view the LICENSE
* File that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/LogicException.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of the @mscs/process package.
*
* Copyright (c) 2020 media-service consulting & solutions GmbH
* Copyright (c) 2021 media-service consulting & solutions GmbH
*
* For the full copyright and license information, please view the LICENSE
* File that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/ProcessException.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of the @mscs/process package.
*
* Copyright (c) 2020 media-service consulting & solutions GmbH
* Copyright (c) 2021 media-service consulting & solutions GmbH
*
* For the full copyright and license information, please view the LICENSE
* File that was distributed with this source code.
Expand Down
3 changes: 2 additions & 1 deletion src/Exception/ProcessFailedException.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/*
* This file is part of the @mscs/process package.
*
* Copyright (c) 2020 media-service consulting & solutions GmbH
* Copyright (c) 2021 media-service consulting & solutions GmbH
*
* For the full copyright and license information, please view the LICENSE
* File that was distributed with this source code.
*/

import * as util from "util";

import { Process } from "../Process/Process";
import { ArgumentException } from "./ArgumentException";
import { RuntimeException } from "./RuntimeException";
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/RuntimeException.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of the @mscs/process package.
*
* Copyright (c) 2020 media-service consulting & solutions GmbH
* Copyright (c) 2021 media-service consulting & solutions GmbH
*
* For the full copyright and license information, please view the LICENSE
* File that was distributed with this source code.
Expand Down
3 changes: 2 additions & 1 deletion src/Input/InputStream.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of the @mscs/process package.
*
* Copyright (c) 2020 media-service consulting & solutions GmbH
* Copyright (c) 2021 media-service consulting & solutions GmbH
*
* For the full copyright and license information, please view the LICENSE
* File that was distributed with this source code.
Expand All @@ -23,6 +23,7 @@ export class InputStream extends Readable {
this.push(null);
} else {
const result = this.contents.slice(0, size);

this.contents = this.contents.slice(size);
this.push(result);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Output/OutputStream.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of the @mscs/process package.
*
* Copyright (c) 2020 media-service consulting & solutions GmbH
* Copyright (c) 2021 media-service consulting & solutions GmbH
*
* For the full copyright and license information, please view the LICENSE
* File that was distributed with this source code.
Expand Down
13 changes: 8 additions & 5 deletions src/Process/Process.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/*
* This file is part of the @mscs/process package.
*
* Copyright (c) 2020 media-service consulting & solutions GmbH
* Copyright (c) 2021 media-service consulting & solutions GmbH
*
* For the full copyright and license information, please view the LICENSE
* File that was distributed with this source code.
*/

import * as childProcess from "child_process";
import * as os from "os";

import { ArgumentException } from "../Exception/ArgumentException";
import { LogicException } from "../Exception/LogicException";
import { ProcessFailedException } from "../Exception/ProcessFailedException";
Expand All @@ -26,17 +27,17 @@ export class Process {

protected args: string[];

protected exitCode: number | null;
protected exitCode!: number | null;

protected options: ProcessOptions;

protected stdout: OutputStream;
protected stdout!: OutputStream;

protected stderr: OutputStream;
protected stderr!: OutputStream;

protected status: ProcessStatus = ProcessStatus.READY;

protected process: childProcess.ChildProcess;
protected process!: childProcess.ChildProcess;

public constructor(command: string[], options: Partial<ProcessOptions> = {}) {
if (command.length === 0) {
Expand Down Expand Up @@ -66,6 +67,7 @@ export class Process {
reject(error);
} else {
const [shellPath] = stdout.replace(/\r?\n/g, "\n").split("\n").filter(item => item.length);

resolve(shellPath);
}
});
Expand Down Expand Up @@ -139,6 +141,7 @@ export class Process {

if (this.options.input && this.process.stdin) {
const stream = new InputStream(this.options.input);

stream.pipe(this.process.stdin);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Process/ProcessOptions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of the @mscs/process package.
*
* Copyright (c) 2020 media-service consulting & solutions GmbH
* Copyright (c) 2021 media-service consulting & solutions GmbH
*
* For the full copyright and license information, please view the LICENSE
* File that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion src/Process/ProcessStatus.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of the @mscs/process package.
*
* Copyright (c) 2020 media-service consulting & solutions GmbH
* Copyright (c) 2021 media-service consulting & solutions GmbH
*
* For the full copyright and license information, please view the LICENSE
* File that was distributed with this source code.
Expand Down
11 changes: 4 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
/*
* This file is part of the @mscs/process package.
*
* Copyright (c) 2020 media-service consulting & solutions GmbH
* Copyright (c) 2021 media-service consulting & solutions GmbH
*
* For the full copyright and license information, please view the LICENSE
* File that was distributed with this source code.
*/

export * from "./Exception/LogicException";
export * from "./Exception/ProcessException";
export * from "./Exception/ProcessFailedException";
export * from "./Exception/LogicException";
export * from "./Exception/RuntimeException";

export * from "./Input/InputStream";

export * from "./Output/OutputStream";

export * from "./Process/ProcessStatus";
export * from "./Process/ProcessOptions";
export * from "./Process/Process";
export * from "./Process/ProcessOptions";
export * from "./Process/ProcessStatus";
9 changes: 2 additions & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
{
"extends": "@tsconfig/node12/tsconfig.json",
"compilerOptions": {
"target": "ES2019",
"module": "commonjs",
"declaration": true,
"sourceMap": true,
"outDir": "./dist",
"strict": true,
"moduleResolution": "node",
"strictPropertyInitialization": false,
"lib": ["ES2019"]
"outDir": "./dist"
},
"include": [
"./src/**/*"
Expand Down
2 changes: 0 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
*/

const path = require("path");
const nodeExternals = require("webpack-node-externals");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");

module.exports = {
target: "node",
entry: "./src/index.ts",
devtool: "source-map",
externals: [nodeExternals()],
module: {
rules: [
{
Expand Down
Loading

0 comments on commit c927e53

Please sign in to comment.