trtc-electron-sdk 11.9.606-beta.13 → 11.9.606-beta.14
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/scripts/utils.js +34 -17
package/package.json
CHANGED
package/scripts/utils.js
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
const semver = require("semver");
|
|
5
5
|
const pkg = require("../package.json");
|
|
6
|
-
const
|
|
6
|
+
const path = require("path");
|
|
7
|
+
|
|
7
8
|
const { Platform } = require("./constant");
|
|
9
|
+
const { platform, arch } = require("os");
|
|
8
10
|
|
|
9
11
|
module.exports.readCliArgv = function () {
|
|
10
12
|
const cliArgv = process.argv;
|
|
@@ -47,25 +49,40 @@ module.exports.readArgvFromNpmEnv = function () {
|
|
|
47
49
|
|
|
48
50
|
module.exports.readArgvFromPkgJson = function () {
|
|
49
51
|
let INIT_CWD = process.env["INIT_CWD"];
|
|
50
|
-
let
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
let pnpm_PkgJsonDir = INIT_CWD;
|
|
53
|
+
INIT_CWD = INIT_CWD.split("/");
|
|
54
|
+
INIT_CWD = INIT_CWD.splice(0, INIT_CWD.length - 2);
|
|
55
|
+
let PkgJsonDir = INIT_CWD.join("/") + "/package.json";
|
|
56
|
+
let rootDirIndex = 0;
|
|
57
|
+
try {
|
|
58
|
+
require(PkgJsonDir);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
if (process.platform === "win32") {
|
|
61
|
+
pnpm_PkgJsonDir = pnpm_PkgJsonDir.split("\\");
|
|
62
|
+
rootDirIndex = pnpm_PkgJsonDir.findIndex(
|
|
63
|
+
(item) => item === "node_modules"
|
|
64
|
+
);
|
|
65
|
+
PkgJsonDir =
|
|
66
|
+
pnpm_PkgJsonDir.splice(0, rootDirIndex).join("\\\\") +
|
|
67
|
+
"\\\\package.json";
|
|
68
|
+
} else {
|
|
69
|
+
pnpm_PkgJsonDir = pnpm_PkgJsonDir.split("/");
|
|
70
|
+
rootDirIndex = pnpm_PkgJsonDir.findIndex(
|
|
71
|
+
(item) => item === "node_modules"
|
|
72
|
+
);
|
|
73
|
+
PkgJsonDir =
|
|
74
|
+
pnpm_PkgJsonDir.splice(0, rootDirIndex).join("/") + "/package.json";
|
|
75
|
+
}
|
|
53
76
|
}
|
|
54
|
-
INIT_CWD = INIT_CWD.split(splitSymbol);
|
|
55
|
-
let rootDirIndex = INIT_CWD.findIndex((item) => item === "node_modules");
|
|
56
|
-
PkgJsonDir =
|
|
57
|
-
INIT_CWD.splice(0, rootDirIndex).join(splitSymbol) +
|
|
58
|
-
`${splitSymbol}package.json`;
|
|
59
|
-
|
|
60
77
|
const { trtc_electron } = require(PkgJsonDir);
|
|
61
|
-
|
|
78
|
+
console.log(
|
|
79
|
+
"INIT_CWD",
|
|
80
|
+
INIT_CWD,
|
|
81
|
+
"PkgJsonDir",
|
|
62
82
|
PkgJsonDir,
|
|
63
|
-
trtc_electron,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
fs.writeFile("./log.txt", JSON.stringify(logObject), (err) => {
|
|
67
|
-
throw err;
|
|
68
|
-
});
|
|
83
|
+
"trtc_electron",
|
|
84
|
+
trtc_electron
|
|
85
|
+
);
|
|
69
86
|
|
|
70
87
|
if (!trtc_electron) {
|
|
71
88
|
return {};
|