Skip to content

Commit

Permalink
fix: remove .json check from require_async, prevent child_process spa…
Browse files Browse the repository at this point in the history
…wn (#18416)
  • Loading branch information
tgriesser authored Oct 8, 2021
1 parent c18b5e6 commit 32464f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
5 changes: 0 additions & 5 deletions packages/server/lib/util/require_async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import * as cp from 'child_process'
import * as inspector from 'inspector'
import * as util from '../plugins/util'
import * as errors from '../errors'
import { fs } from '../util/fs'
import Debug from 'debug'

const debug = Debug('cypress:server:require_async')
Expand Down Expand Up @@ -33,10 +32,6 @@ export async function requireAsync (filePath: string, options: RequireAsyncOptio
killChildProcess()
}

if (/\.json$/.test(filePath)) {
fs.readJson(path.resolve(options.projectRoot, filePath)).then((result) => resolve(result)).catch(reject)
}

const childOptions: ChildOptions = {
stdio: 'inherit',
}
Expand Down
12 changes: 7 additions & 5 deletions packages/server/lib/util/settings.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import _ from 'lodash'
import Promise from 'bluebird'
import path from 'path'

import errors from '../errors'
import { fs } from '../util/fs'
import { requireAsync } from './require_async'
Expand Down Expand Up @@ -146,11 +147,12 @@ export function read (projectRoot, options: SettingsOptions = {}) {

const file = pathToConfigFile(projectRoot, options)

return requireAsync(file,
{
projectRoot,
loadErrorCode: 'CONFIG_FILE_ERROR',
})
const readPromise = /\.json$/.test(file) ? fs.readJSON(path.resolve(projectRoot, file)) : requireAsync(file, {
projectRoot,
loadErrorCode: 'CONFIG_FILE_ERROR',
})

return readPromise
.catch((err) => {
if (err.type === 'MODULE_NOT_FOUND' || err.code === 'ENOENT') {
if (options.args?.runProject) {
Expand Down

4 comments on commit 32464f3

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 32464f3 Oct 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/8.6.0/circle-develop-32464f3b5b4cf034cd19af7881e124c30d205f36/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 32464f3 Oct 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 ia32 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/8.6.0/appveyor-develop-32464f3b5b4cf034cd19af7881e124c30d205f36/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 32464f3 Oct 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/8.6.0/appveyor-develop-32464f3b5b4cf034cd19af7881e124c30d205f36/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 32464f3 Oct 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/8.6.0/circle-develop-32464f3b5b4cf034cd19af7881e124c30d205f36/cypress.tgz

Please sign in to comment.