|
5 | 5 | * - detectExecutableType() generic entry point routing |
6 | 6 | * - detectDlxExecutableType() detects packages vs binaries in DLX cache |
7 | 7 | * - detectLocalExecutableType() detects via package.json and file extensions |
8 | | - * - isNodeJsExtension() validates .js, .mjs, .cjs extensions |
| 8 | + * - isJsFilePath() validates .js, .mjs, .cjs file paths |
9 | 9 | * - isNodePackage() simplified helper for package detection |
10 | 10 | * - isNativeBinary() simplified helper for binary detection |
11 | 11 | * |
@@ -34,8 +34,8 @@ import { |
34 | 34 | detectDlxExecutableType, |
35 | 35 | detectExecutableType, |
36 | 36 | detectLocalExecutableType, |
| 37 | + isJsFilePath, |
37 | 38 | isNativeBinary, |
38 | | - isNodeJsExtension, |
39 | 39 | isNodePackage, |
40 | 40 | } from '@socketsecurity/lib/dlx/detect' |
41 | 41 | import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs' |
@@ -281,33 +281,33 @@ describe('DLX Executable Type Detection', () => { |
281 | 281 | }) |
282 | 282 | }) |
283 | 283 |
|
284 | | - describe('isNodeJsExtension', () => { |
| 284 | + describe('isJsFilePath', () => { |
285 | 285 | it('should return true for .js files', () => { |
286 | | - expect(isNodeJsExtension('/path/to/file.js')).toBe(true) |
287 | | - expect(isNodeJsExtension('file.js')).toBe(true) |
| 286 | + expect(isJsFilePath('/path/to/file.js')).toBe(true) |
| 287 | + expect(isJsFilePath('file.js')).toBe(true) |
288 | 288 | }) |
289 | 289 |
|
290 | 290 | it('should return true for .mjs files', () => { |
291 | | - expect(isNodeJsExtension('/path/to/module.mjs')).toBe(true) |
292 | | - expect(isNodeJsExtension('module.mjs')).toBe(true) |
| 291 | + expect(isJsFilePath('/path/to/module.mjs')).toBe(true) |
| 292 | + expect(isJsFilePath('module.mjs')).toBe(true) |
293 | 293 | }) |
294 | 294 |
|
295 | 295 | it('should return true for .cjs files', () => { |
296 | | - expect(isNodeJsExtension('/path/to/common.cjs')).toBe(true) |
297 | | - expect(isNodeJsExtension('common.cjs')).toBe(true) |
| 296 | + expect(isJsFilePath('/path/to/common.cjs')).toBe(true) |
| 297 | + expect(isJsFilePath('common.cjs')).toBe(true) |
298 | 298 | }) |
299 | 299 |
|
300 | 300 | it('should be case-insensitive', () => { |
301 | | - expect(isNodeJsExtension('FILE.JS')).toBe(true) |
302 | | - expect(isNodeJsExtension('MODULE.MJS')).toBe(true) |
303 | | - expect(isNodeJsExtension('COMMON.CJS')).toBe(true) |
| 301 | + expect(isJsFilePath('FILE.JS')).toBe(true) |
| 302 | + expect(isJsFilePath('MODULE.MJS')).toBe(true) |
| 303 | + expect(isJsFilePath('COMMON.CJS')).toBe(true) |
304 | 304 | }) |
305 | 305 |
|
306 | 306 | it('should return false for non-Node.js extensions', () => { |
307 | | - expect(isNodeJsExtension('/path/to/binary')).toBe(false) |
308 | | - expect(isNodeJsExtension('/path/to/file.py')).toBe(false) |
309 | | - expect(isNodeJsExtension('/path/to/file.sh')).toBe(false) |
310 | | - expect(isNodeJsExtension('/path/to/file.exe')).toBe(false) |
| 307 | + expect(isJsFilePath('/path/to/binary')).toBe(false) |
| 308 | + expect(isJsFilePath('/path/to/file.py')).toBe(false) |
| 309 | + expect(isJsFilePath('/path/to/file.sh')).toBe(false) |
| 310 | + expect(isJsFilePath('/path/to/file.exe')).toBe(false) |
311 | 311 | }) |
312 | 312 | }) |
313 | 313 |
|
|
0 commit comments