@formatjs/cli 6.16.8 → 6.16.10
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/bin/formatjs +21 -5
- package/bin/formatjs.map +1 -1
- package/package.json +7 -5
package/bin/formatjs
CHANGED
|
@@ -12320,18 +12320,34 @@ function getStdinAsString() {
|
|
|
12320
12320
|
//#region packages/cli-lib/native.ts
|
|
12321
12321
|
const require$1 = createRequire$1(import.meta.url);
|
|
12322
12322
|
const NATIVE_PACKAGES = {
|
|
12323
|
-
"darwin-arm64": "@formatjs/cli-native-darwin-arm64",
|
|
12324
|
-
"linux-arm64": "@formatjs/cli-native-linux-arm64",
|
|
12325
|
-
"linux-x64": "@formatjs/cli-native-linux-x64",
|
|
12326
|
-
"win32-x64": "@formatjs/cli-native-win32-x64"
|
|
12323
|
+
"darwin-arm64": ["@formatjs/cli-native-darwin-arm64"],
|
|
12324
|
+
"linux-arm64": ["@formatjs/cli-native-linux-arm64", "@formatjs/cli-native-linux-arm64-musl"],
|
|
12325
|
+
"linux-x64": ["@formatjs/cli-native-linux-x64", "@formatjs/cli-native-linux-x64-musl"],
|
|
12326
|
+
"win32-x64": ["@formatjs/cli-native-win32-x64"]
|
|
12327
12327
|
};
|
|
12328
12328
|
let nativeBinding;
|
|
12329
|
+
function getInstalledNativePackageCandidates(candidates, canResolve = (candidate) => {
|
|
12330
|
+
try {
|
|
12331
|
+
require$1.resolve(candidate);
|
|
12332
|
+
return true;
|
|
12333
|
+
} catch {
|
|
12334
|
+
return false;
|
|
12335
|
+
}
|
|
12336
|
+
}) {
|
|
12337
|
+
return candidates.filter(canResolve);
|
|
12338
|
+
}
|
|
12339
|
+
function getNativePackageCandidates(platform = process.platform, arch = process.arch) {
|
|
12340
|
+
return NATIVE_PACKAGES[`${platform}-${arch}`] || [];
|
|
12341
|
+
}
|
|
12329
12342
|
function loadNative() {
|
|
12330
12343
|
if (nativeBinding !== void 0) {
|
|
12331
12344
|
if (nativeBinding) return nativeBinding;
|
|
12332
12345
|
throw new Error("Native @formatjs/cli-lib binding is unavailable");
|
|
12333
12346
|
}
|
|
12334
|
-
const
|
|
12347
|
+
const overridePath = process.env.FORMATJS_CLI_LIB_NATIVE_PATH;
|
|
12348
|
+
const packageCandidates = getNativePackageCandidates();
|
|
12349
|
+
const installedPackageCandidates = getInstalledNativePackageCandidates(packageCandidates);
|
|
12350
|
+
const candidates = [overridePath, ...installedPackageCandidates.length ? installedPackageCandidates : packageCandidates].filter(Boolean);
|
|
12335
12351
|
const loadErrors = [];
|
|
12336
12352
|
for (const candidate of candidates) try {
|
|
12337
12353
|
nativeBinding = require$1(candidate);
|