Skip to content

Commit

Permalink
fix: remove NODE_ENV=test condition (#1499)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnalborczyk authored Jul 2, 2022
1 parent 14fc457 commit 2eec40a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
9 changes: 1 addition & 8 deletions src/ServerlessOffline.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,10 @@ export default class ServerlessOffline {
}

async ready() {
if (env.NODE_ENV !== 'test') {
await this.#listenForTermination()
}
await this.#listenForTermination()
}

async end(skipExit) {
// TEMP FIXME
if (env.NODE_ENV === 'test' && skipExit === undefined) {
return
}

log.info('Halting offline server')

const eventModules = []
Expand Down
20 changes: 9 additions & 11 deletions src/events/http/HttpServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Buffer } from 'node:buffer'
import { readFileSync } from 'node:fs'
import { createRequire } from 'node:module'
import { join, resolve } from 'node:path'
import process, { env, exit } from 'node:process'
import process, { exit } from 'node:process'
import h2o2 from '@hapi/h2o2'
import { Server } from '@hapi/hapi'
import { log } from '@serverless/utils/log.js'
Expand Down Expand Up @@ -202,16 +202,14 @@ export default class HttpServer {
log.notice()
log.notice('Enter "rp" to replay the last request')

if (env.NODE_ENV !== 'test') {
process.openStdin().addListener('data', (data) => {
// note: data is an object, and when converted to a string it will
// end with a linefeed. so we (rather crudely) account for that
// with toString() and then trim()
if (data.toString().trim() === 'rp') {
this.#injectLastRequest()
}
})
}
process.openStdin().addListener('data', (data) => {
// note: data is an object, and when converted to a string it will
// end with a linefeed. so we (rather crudely) account for that
// with toString() and then trim()
if (data.toString().trim() === 'rp') {
this.#injectLastRequest()
}
})
}

// stops the server
Expand Down

0 comments on commit 2eec40a

Please sign in to comment.