Skip to content

Commit

Permalink
Prefer native EventEmitter
Browse files Browse the repository at this point in the history
  • Loading branch information
anmiles committed Apr 25, 2024
1 parent 8e2bc01 commit afb997c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 113 deletions.
107 changes: 0 additions & 107 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"@anmiles/eslint-config": "^7.1.2",
"@anmiles/tsconfig": "^3.0.2",
"@stylistic/eslint-plugin": "^1.7.0",
"@types/event-emitter": "^0.3.5",
"@types/jest": "^29.5.12",
"@types/mock-fs": "^4.13.4",
"@typescript-eslint/eslint-plugin": "^7.4.0",
Expand All @@ -46,7 +45,6 @@
"eslint-plugin-jsonc": "^2.14.1",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-promise": "^6.1.1",
"event-emitter": "^0.3.5",
"jest": "^29.7.0",
"mock-fs": "^5.2.0",
"nyc": "^15.1.0",
Expand Down
8 changes: 4 additions & 4 deletions src/lib/__tests__/process.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import '../process';
import type path from 'path';
import childProcess from 'child_process';
import emitter from 'event-emitter';
import EventEmitter from 'events';

const pathOriginal = jest.requireActual<typeof path>('path');
jest.mock<Partial<typeof path>>('path', () => ({
Expand All @@ -21,14 +21,14 @@ const stdout = jest.fn();
const stderr = jest.fn();

function spawn(): childProcess.ChildProcess {
const instance = emitter() as ReturnType<typeof childProcess.spawn>;
const instance = new EventEmitter() as ReturnType<typeof childProcess.spawn>;

if (hasStdout) {
instance.stdout = emitter() as ReturnType<typeof childProcess.spawn>['stdout'];
instance.stdout = new EventEmitter() as ReturnType<typeof childProcess.spawn>['stdout'];
}

if (hasStderr) {
instance.stderr = emitter() as ReturnType<typeof childProcess.spawn>['stderr'];
instance.stderr = new EventEmitter() as ReturnType<typeof childProcess.spawn>['stderr'];
}

return spawned = instance;
Expand Down

0 comments on commit afb997c

Please sign in to comment.