Skip to content

Commit

Permalink
ESlint
Browse files Browse the repository at this point in the history
  • Loading branch information
kevgo committed Oct 2, 2020
1 parent 6a55ce5 commit 943120a
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
@@ -0,0 +1,2 @@
dist
node_modules
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -9,14 +9,14 @@ coverage: build # measures test coverage
${CURDIR}/node_modules/.bin/nyc report --reporter=text-lcov | node_modules/.bin/coveralls

fix: # runs the fixers
tslint --project . --fix
${CURDIR}/node_modules/.bin/eslint . --fix --ext .ts --ignore-path .eslintignore
${CURDIR}/node_modules/.bin/prettier --write .

help: # prints all make targets
cat Makefile | grep '^[^ ]*:' | grep -v '.PHONY' | grep -v help | sed 's/:.*#/#/' | column -s "#" -t

lint: # runs the linters
${CURDIR}/node_modules/.bin/tslint --project .
${CURDIR}/node_modules/.bin/eslint . --ext .ts --ignore-path .eslintignore
${CURDIR}/node_modules/.bin/prettier -l .

setup: # sets up the installation on this machine
Expand Down
7 changes: 4 additions & 3 deletions src/observable-process.ts
@@ -1,8 +1,9 @@
import * as childProcess from "child_process"
import mergeStream = require("merge-stream")
import { createSearchableStream, SearchableStream } from "./searchable-stream"
import * as util from "util"

import { Result } from "./result"
import { createSearchableStream, SearchableStream } from "./searchable-stream"
const delay = util.promisify(setTimeout)

/** a long-running process whose behavior can be observed at runtime */
Expand All @@ -28,7 +29,7 @@ export class ObservableProcess {
/** functions to call when this process ends */
private endedCallbacks: Array<(result: Result) => void>

constructor(args: { runnable: string; params: string[]; cwd: string; env: NodeJS.ProcessEnv }) {
constructor(args: { cwd: string; env: NodeJS.ProcessEnv; params: string[]; runnable: string }) {
this.endedCallbacks = []
this.process = childProcess.spawn(args.runnable, args.params, {
cwd: args.cwd,
Expand Down Expand Up @@ -66,7 +67,7 @@ export class ObservableProcess {
}

/** returns the process ID of the underlying ChildProcess */
pid() {
pid(): number {
return this.process.pid
}

Expand Down
12 changes: 6 additions & 6 deletions src/result.ts
@@ -1,5 +1,11 @@
/** Provides the results of running the process */
export interface Result {
/** combined output from STDOUT and STDERR */
combinedText: string

/** full output on the STDERR stream */
errText: string

/** the code with which the process has ended */
exitCode: number

Expand All @@ -8,10 +14,4 @@ export interface Result {

/** full output on the STDOUT stream */
stdText: string

/** full output on the STDERR stream */
errText: string

/** combined output from STDOUT and STDERR */
combinedText: string
}
2 changes: 1 addition & 1 deletion src/searchable-stream.ts
Expand Up @@ -5,8 +5,8 @@ import { TextStreamSearch } from "text-stream-search"
*/
export interface TextStreamSearcher {
fullText(): string
waitForText(text: string, timeout?: number): Promise<string>
waitForRegex(regex: RegExp, timeout?: number): Promise<string>
waitForText(text: string, timeout?: number): Promise<string>
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/start.ts
@@ -1,4 +1,5 @@
import stringArgv from "string-argv"

import { ObservableProcess } from "./observable-process"

/** The options that can be provided to Spawn */
Expand Down
1 change: 1 addition & 0 deletions test/input-test.ts
@@ -1,4 +1,5 @@
import { strict as assert } from "assert"

import { startNodeProcess } from "./helpers/start-node-process"

test("ObservableProcess.stdin", async function () {
Expand Down
3 changes: 2 additions & 1 deletion test/kill-test.ts
@@ -1,6 +1,7 @@
import { strict as assert } from "assert"
import got from "got"
import * as portFinder from "portfinder"

import { startNodeProcess } from "./helpers/start-node-process"

test("ObservableProcess.kill()", async function () {
Expand All @@ -13,7 +14,7 @@ test("ObservableProcess.kill()", async function () {
http.createServer(function(_, res) { res.end('hello') }).listen(${port}, 'localhost');\
console.log('online')`
)
longRunningProcess.stdout.waitForText("online")
await longRunningProcess.stdout.waitForText("online")
await assertIsRunning(port)

// kill the process
Expand Down
1 change: 1 addition & 0 deletions test/output-test.ts
@@ -1,4 +1,5 @@
import { strict as assert } from "assert"

import { startNodeProcess } from "./helpers/start-node-process"

suite("ObservableProcess.output")
Expand Down
1 change: 1 addition & 0 deletions test/pid-test.ts
@@ -1,4 +1,5 @@
import { strict as assert } from "assert"

import { startNodeProcess } from "./helpers/start-node-process"

test("ObservableProcess.pid()", async function () {
Expand Down
1 change: 1 addition & 0 deletions test/start-test.ts
@@ -1,4 +1,5 @@
import { strict as assert } from "assert"

import { start } from "../src/start"

suite("ObservableProcess.spawn()")
Expand Down
1 change: 1 addition & 0 deletions test/stderr-test.ts
@@ -1,4 +1,5 @@
import { strict as assert } from "assert"

import { startNodeProcess } from "./helpers/start-node-process"

suite("ObservableProcess.stderr")
Expand Down
1 change: 1 addition & 0 deletions test/stdout-test.ts
@@ -1,4 +1,5 @@
import { strict as assert } from "assert"

import { startNodeProcess } from "./helpers/start-node-process"

suite("ObservableProcess.stdout")
Expand Down
3 changes: 2 additions & 1 deletion test/wait-for-end-test.ts
@@ -1,6 +1,7 @@
import { strict as assert } from "assert"
import { start } from "../src/start"
import * as util from "util"

import { start } from "../src/start"
const delay = util.promisify(setTimeout)

suite("ObservableProcess.waitForEnd()")
Expand Down

0 comments on commit 943120a

Please sign in to comment.