@take2identity/verosint 0.2.74 → 0.2.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/postinstall.js +12 -16
package/package.json
CHANGED
package/postinstall.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"use strict"
|
|
4
4
|
|
|
5
5
|
const { join } = require('path');
|
|
6
|
-
const {
|
|
6
|
+
const { spawnSync } = require('child_process');
|
|
7
7
|
const { existsSync, chmodSync, copyFileSync, unlinkSync, createWriteStream, readFileSync } = require('fs');
|
|
8
8
|
const mkdirp = require('mkdirp');
|
|
9
9
|
const axios = require('axios')
|
|
@@ -27,31 +27,27 @@ const PLATFORM_MAPPING = {
|
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
function getInstallationPath(callback) {
|
|
30
|
-
|
|
31
30
|
// `npm bin` will output the path where binary files should be installed
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
const {err, stdout, stderr} = spawnSync('npm bin');
|
|
32
|
+
let dir = null;
|
|
33
|
+
if (err || stderr || !stdout || stdout.length === 0) {
|
|
36
34
|
// We couldn't infer path from `npm bin`. Let's try to get it from
|
|
37
35
|
// Environment variables set by NPM when it runs.
|
|
38
36
|
// npm_config_prefix points to NPM's installation directory where `bin` folder is available
|
|
39
37
|
// Ex: /Users/foo/.nvm/versions/node/v4.3.0
|
|
40
38
|
const env = process.env;
|
|
41
|
-
|
|
42
39
|
if (env?.npm_config_prefix) {
|
|
43
|
-
|
|
40
|
+
dir = join(env.npm_config_prefix, 'bin');
|
|
44
41
|
} else {
|
|
45
|
-
|
|
42
|
+
return callback(new Error('Error finding binary installation directory'));
|
|
46
43
|
}
|
|
47
|
-
|
|
44
|
+
} else {
|
|
48
45
|
dir = stdout.trim();
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
dir = dir.replace(/node_modules.*[/\\]\.bin/, join('node_modules', '.bin'));
|
|
49
|
+
mkdirp.sync(dir);
|
|
50
|
+
callback(null, dir);
|
|
55
51
|
}
|
|
56
52
|
|
|
57
53
|
function verifyAndPlaceBinary(binName, callback) {
|