Skip to content

Commit

Permalink
fix: Fixes erroneous non-null args.env check (#872)
Browse files Browse the repository at this point in the history
* Fixes erroneous not-null check

* Code format and updated test.

* Changelog

Co-authored-by: Damjan Cvetko <[email protected]>
  • Loading branch information
Keanu73 and zobo authored Dec 13, 2022
1 parent f2546fd commit 0a7a837
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## [1.29.1]

- Fix for env configuration check that sometimes causes an error.

## [1.29.0]

- Xdebug Cloud support.
Expand Down
7 changes: 6 additions & 1 deletion src/phpDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,12 @@ class PhpDebugSession extends vscode.DebugSession {
})
try {
// Some checks
if (args.env !== undefined && args.program === undefined && args.runtimeArgs === undefined) {
if (
args.env &&
Object.keys(args.env).length !== 0 &&
args.program === undefined &&
args.runtimeArgs === undefined
) {
throw new Error(
`Cannot set env without running a program.\nPlease remove env from [${
args.name || 'unknown'
Expand Down
2 changes: 1 addition & 1 deletion src/test/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('PHP Debug Adapter', () => {
))

it('should error on env without program', () =>
assert.isRejected(Promise.all([client.launch({ env: {} }), client.configurationSequence()])))
assert.isRejected(Promise.all([client.launch({ env: { some: 'key' } }), client.configurationSequence()])))

it('should run program to the end', () =>
Promise.all([
Expand Down

0 comments on commit 0a7a837

Please sign in to comment.