Skip to content

Commit

Permalink
fix: snap versions in alternate install locations resulting in warning
Browse files Browse the repository at this point in the history
Fixes #1239
  • Loading branch information
connor4312 committed May 17, 2022
1 parent c8a3004 commit 4692387
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

This changelog records changes to stable releases since 1.50.2. "TBA" changes here may be available in the [nightly release](https://github.com/microsoft/vscode-js-debug/#nightly-extension) before they're in stable. Note that the minor version (`v1.X.0`) corresponds to the VS Code version js-debug is shipped in, but the patch version (`v1.50.X`) is not meaningful.

### Nightly (only)

- fix: snap versions in alternate install locations resulting in warning ([#1239](https://github.com/microsoft/vscode-js-debug/issues/1239))
- fix: align hoverEvaluation config suggestion with actual default
- fix: remove query strings from sourcemapped URLs ([#1225](https://github.com/microsoft/vscode-js-debug/issues/1225))
- fix: prefer to parse source map directly before failling back to path mapping ([vscode#148864](https://github.com/microsoft/vscode/issues/148864))
- fix: only enter debug mode on f11 when debug view is visible ([vscode#141157](https://github.com/microsoft/vscode/issues/141157))

## v1.67 (April 2022)

### v1.67.2 - 2022-04-29
Expand Down
9 changes: 9 additions & 0 deletions src/targets/node/nodeBinaryProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,15 @@ describe('NodeBinaryProvider', function () {
expect(binary.version).to.be.undefined;
expect(getVersionText.called).to.be.false;
});

it('assumes binaries are good if no stdout', async () => {
getVersionText.resolves('');
resolveBinaryLocation.withArgs('node').returns('/snap-alt/bin/node');

const binary = await p.resolveAndValidate(EnvironmentVars.empty);
expect(binary.path).to.equal('/snap-alt/bin/node');
expect(binary.version).to.be.undefined;
});
});
});

Expand Down
13 changes: 10 additions & 3 deletions src/targets/node/nodeBinaryProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,18 @@ export class NodeBinaryProvider {

// match the "12" in "v12.34.56"
const versionText = await this.getVersionText(location);
this.logger.info(LogTag.RuntimeLaunch, 'Discovered version', { version: versionText.trim() });

// Handle other cases where Node.js is installed via snap, but not in `/span/`.
// We just get empty output from it in that case.
if (!versionText) {
return new NodeBinary(location, undefined);
}

this.logger.info(LogTag.RuntimeLaunch, 'Discovered version', { version: versionText });

const majorVersionMatch = /v([0-9]+)\.([0-9]+)\.([0-9]+)/.exec(versionText);
if (!majorVersionMatch) {
throw new NodeBinaryOutOfDateError(versionText.trim(), location);
throw new NodeBinaryOutOfDateError(versionText, location);
}

const [, major, minor, patch] = majorVersionMatch.map(Number);
Expand Down Expand Up @@ -342,7 +349,7 @@ export class NodeBinaryProvider {
const { stdout } = await spawnAsync(binary, ['--version'], {
env: EnvironmentVars.processEnv().defined(),
});
return stdout;
return stdout.trim();
} catch (e) {
throw new ProtocolError(
cannotFindNodeBinary(
Expand Down

0 comments on commit 4692387

Please sign in to comment.