fnva 0.0.12 → 0.0.13
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/fnva.js +33 -11
- package/package.json +1 -1
- package/platforms/fnva +0 -0
- package/platforms/fnva.exe +0 -0
package/bin/fnva.js
CHANGED
|
@@ -314,28 +314,50 @@ function handleNodeOnlyMode(args) {
|
|
|
314
314
|
} else {
|
|
315
315
|
console.log('Available java environments:');
|
|
316
316
|
versions.forEach(version => {
|
|
317
|
-
const
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
317
|
+
const versionDir = path.join(fnvaDir, version);
|
|
318
|
+
const jdkSubdirs = fs.readdirSync(versionDir, { withFileTypes: true })
|
|
319
|
+
.filter(dirent => dirent.isDirectory())
|
|
320
|
+
.map(dirent => dirent.name);
|
|
321
|
+
|
|
322
|
+
if (jdkSubdirs.length > 0) {
|
|
323
|
+
const jdkSubdir = jdkSubdirs[0];
|
|
324
|
+
const fullJdkPath = path.join(versionDir, jdkSubdir);
|
|
325
|
+
|
|
326
|
+
if (fs.existsSync(path.join(fullJdkPath, 'release'))) {
|
|
327
|
+
try {
|
|
328
|
+
const releaseContent = fs.readFileSync(path.join(fullJdkPath, 'release'), 'utf8');
|
|
329
|
+
const versionMatch = releaseContent.match(/JAVA_VERSION="(.+)"/);
|
|
330
|
+
const javaVersion = versionMatch ? versionMatch[1].replace(/"/g, '') : 'Unknown';
|
|
331
|
+
console.log(` ${version} (current): Java ${javaVersion} (${fullJdkPath})`);
|
|
332
|
+
} catch (e) {
|
|
333
|
+
console.log(` ${version} (${fullJdkPath})`);
|
|
334
|
+
}
|
|
326
335
|
}
|
|
327
336
|
}
|
|
328
337
|
});
|
|
329
338
|
}
|
|
330
339
|
} else if (args[1] === 'use' && args[2]) {
|
|
331
340
|
const version = args[2];
|
|
332
|
-
const
|
|
341
|
+
const versionDir = path.join(fnvaDir, version);
|
|
333
342
|
|
|
334
|
-
if (!fs.existsSync(
|
|
343
|
+
if (!fs.existsSync(versionDir)) {
|
|
335
344
|
console.error(`Java environment '${version}' not found`);
|
|
336
345
|
process.exit(1);
|
|
337
346
|
}
|
|
338
347
|
|
|
348
|
+
// 查找实际的 JDK 目录
|
|
349
|
+
const jdkSubdirs = fs.readdirSync(versionDir, { withFileTypes: true })
|
|
350
|
+
.filter(dirent => dirent.isDirectory())
|
|
351
|
+
.map(dirent => dirent.name);
|
|
352
|
+
|
|
353
|
+
if (jdkSubdirs.length === 0) {
|
|
354
|
+
console.error(`No JDK installation found in ${versionDir}`);
|
|
355
|
+
process.exit(1);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
const jdkPath = path.join(versionDir, jdkSubdirs[0]);
|
|
359
|
+
const jdkBinPath = path.join(jdkPath, 'bin');
|
|
360
|
+
|
|
339
361
|
// 生成环境切换脚本
|
|
340
362
|
const envVars = {
|
|
341
363
|
JAVA_HOME: jdkPath
|
package/package.json
CHANGED
package/platforms/fnva
CHANGED
|
Binary file
|
package/platforms/fnva.exe
CHANGED
|
Binary file
|