Skip to content

Commit

Permalink
Set version using a sync process
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego Henrique Oliveira authored and Dexus committed Apr 4, 2023
1 parent 3f7cbce commit 6b27908
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
11 changes: 8 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions lib/openssl.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var helper = require('./helper.js')
var {debug} = require('./debug.js')
var cpspawn = require('child_process').spawn
var spawnSync = require('child_process').spawnSync
var pathlib = require('path')
var fs = require('fs')
var osTmpdir = require('os-tmpdir')
Expand Down Expand Up @@ -261,8 +262,10 @@ function testOpenSSLPath(pathBin, callback) {
}

/* Once PEM is imported, the openSslVersion is set with this function. */
spawn(['version'], false, function (err, code, stdout, stderr) {
var text = String(stdout) + '\n' + String(stderr) + '\n' + String(err)
function setVersion() {
var pathBin = get('pathOpenSSL') || process.env.OPENSSL_BIN || 'openssl'
var output = spawnSync(pathBin, ['version'])
var text = String(output.stdout) + '\n' + String(output.stderr) + '\n' + String(output.error)
let version = versionRegEx.exec(text)
if (version === null || version.length <= 7) return
set('openSslVersion', (version[1]).toUpperCase())
Expand All @@ -273,7 +276,9 @@ spawn(['version'], false, function (err, code, stdout, stderr) {
set('VendorVersionMinor', version[5])
set('VendorVersionPatch', version[6])
set('VendorVersionBuildChar', typeof version[7] === 'undefined' ? '' : version[7])
})
};

setVersion();

module.exports = {
exec: exec,
Expand Down

0 comments on commit 6b27908

Please sign in to comment.