mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-02 08:33:36 +00:00
feat(platform): add executable permission validation to node-finder
- Add isExecutable() helper to verify files have execute permission - On Unix: uses fs.constants.X_OK to check execute permission - On Windows: only checks file existence (X_OK not meaningful) - Replace fs.existsSync with isExecutable for all node path checks - Add JSDoc comment documenting version sorting limitations - Add test to verify found node binary is executable 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||
import { findNodeExecutable, buildEnhancedPath } from '../src/node-finder.js';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
|
||||
describe('node-finder', () => {
|
||||
describe('findNodeExecutable', () => {
|
||||
@@ -51,6 +52,25 @@ describe('node-finder', () => {
|
||||
];
|
||||
expect(validSources).toContain(result.source);
|
||||
});
|
||||
|
||||
it('should find an executable node binary', () => {
|
||||
const result = findNodeExecutable();
|
||||
|
||||
// Skip this test if fallback is used (node not found via path search)
|
||||
if (result.source === 'fallback') {
|
||||
expect(result.nodePath).toBe('node');
|
||||
return;
|
||||
}
|
||||
|
||||
// Verify the found path is actually executable
|
||||
if (process.platform === 'win32') {
|
||||
// On Windows, just check file exists (X_OK is not meaningful)
|
||||
expect(() => fs.accessSync(result.nodePath, fs.constants.F_OK)).not.toThrow();
|
||||
} else {
|
||||
// On Unix-like systems, verify execute permission
|
||||
expect(() => fs.accessSync(result.nodePath, fs.constants.X_OK)).not.toThrow();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('buildEnhancedPath', () => {
|
||||
|
||||
Reference in New Issue
Block a user