11const fs = require ( 'node:fs' )
22const path = require ( 'node:path' )
3- const { execSync } = require ( 'node:child_process' )
4- const { isWindows, findExecutable, extractVersionFromPath, normalizePathSeparators } = require ( '../../platform-utils' )
3+ const { isWindows } = require ( '../../platform-utils' )
4+ const platformUtils = require ( '../../platform-utils' )
5+ const childProcess = require ( 'node:child_process' )
56
67/**
78 * Try to detect Node.js version from n (Node.js version manager by TJ)
@@ -73,11 +74,11 @@ function detectNodeVersionFromN () {
7374
7475 // Strategy 4: Check where node points to n-managed version (cross-platform)
7576 try {
76- const nodePath = findExecutable ( 'node' )
77+ const nodePath = platformUtils . findExecutable ( 'node' )
7778 if ( nodePath ) {
78- const normalizedPath = normalizePathSeparators ( nodePath )
79+ const normalizedPath = platformUtils . normalizePathSeparators ( nodePath )
7980 if ( normalizedPath . includes ( '/n/versions/node/' ) ) {
80- const version = extractVersionFromPath ( normalizedPath )
81+ const version = platformUtils . extractVersionFromPath ( normalizedPath )
8182 if ( version ) {
8283 return `v${ version } `
8384 }
@@ -89,13 +90,13 @@ function detectNodeVersionFromN () {
8990
9091 // Strategy 5: Try n command as fallback (simplified, no shell redirection)
9192 try {
92- const version = execSync ( 'n bin' , {
93+ const version = childProcess . execSync ( 'n bin' , {
9394 encoding : 'utf-8' ,
9495 stdio : [ 'pipe' , 'pipe' , 'ignore' ] ,
9596 timeout : 2000
9697 } ) . trim ( )
9798
98- const extractedVersion = extractVersionFromPath ( normalizePathSeparators ( version ) )
99+ const extractedVersion = platformUtils . extractVersionFromPath ( platformUtils . normalizePathSeparators ( version ) )
99100 if ( extractedVersion ) {
100101 return `v${ extractedVersion } `
101102 }
0 commit comments