Skip to content

Commit

Permalink
Fix to work in VS Code context
Browse files Browse the repository at this point in the history
it avoids to rely on `process.execPath` which resolves to `code` binary
in VS Code context although it expects the `node` binary

relates to asciidoctor/asciidoctor-vscode#731

Signed-off-by: Aurélien Pupier <apupier@redhat.com>
  • Loading branch information
apupier committed Aug 8, 2023
1 parent 4fbc399 commit 6897f06
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/XMLHttpRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,10 +517,9 @@ exports.XMLHttpRequest = function () {
: DEFAULT_MAX_BUFFER
const encoding = responseType === 'text' ? 'utf8' : 'binary'
const scriptPath = ospath.join(__dirname, 'request.js')
const output = require('child_process').execSync(`"${process.execPath}" "${scriptPath}" \
--ssl="${ssl}" \
--encoding="${encoding}" \
--request-options=${JSON.stringify(JSON.stringify(options))}`, { stdio: ['pipe', 'pipe', 'pipe'], input: data, maxBuffer: maxBuffer })
const output = require('child_process').execFileSync(scriptPath,
[`--ssl="${ssl}"`, `--encoding="${encoding}"`, `--request-options=${JSON.stringify(JSON.stringify(options))}`],
{ stdio: ['pipe', 'pipe', 'pipe'], input: data, maxBuffer: maxBuffer })
const result = JSON.parse(output.toString('utf8'))
if (result.error) {
throw translateError(result.error, url)
Expand Down

0 comments on commit 6897f06

Please sign in to comment.