Skip to content

Commit e57fdcc

Browse files
committed
lib: assign localAppData and programFiles from env
These paths may be localized to other languages, or placed on another drive. (These paths appear to be mostly standardized on Windows 10, but supposedly they were more flexible (or were located elsewhere) on some older version(s) of Windows.)
1 parent d0bcb5c commit e57fdcc

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/find-python.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,19 @@ const win = process.platform === 'win32'
88
const logWithPrefix = require('./util').logWithPrefix
99

1010
const systemDrive = process.env.SystemDrive || 'C:'
11+
const programFiles = process.env.ProgramFiles || `${systemDrive}\\Program Files`
12+
const programFilesX86 = process.env['ProgramFiles(x86)'] || `${programFiles} (x86)`
1113
const username = process.env.USERNAME || process.env.USER
12-
const winDefaultLocationsArray = []
14+
const localAppData = process.env.LOCALAPPDATA || `${systemDrive}\\${username}\\AppData\\Local`
1315

16+
const winDefaultLocationsArray = []
1417
for (const majorMinor of ['39', '38', '37', '36']) {
1518
winDefaultLocationsArray.push(
16-
`${systemDrive}\\Users\\${username}\\AppData\\Local\\Programs\\Python\\Python${majorMinor}\\python.exe`,
17-
`${systemDrive}\\Program Files\\Python${majorMinor}\\python.exe`,
18-
`${systemDrive}\\Users\\${username}\\AppData\\Local\\Programs\\Python\\Python${majorMinor}-32\\python.exe`,
19-
`${systemDrive}\\Program Files\\Python${majorMinor}-32\\python.exe`,
20-
`${systemDrive}\\Program Files (x86)\\Python${majorMinor}-32\\python.exe`
19+
`${localAppData}\\Programs\\Python\\Python${majorMinor}\\python.exe`,
20+
`${programFiles}\\Python${majorMinor}\\python.exe`,
21+
`${localAppData}\\Programs\\Python\\Python${majorMinor}-32\\python.exe`,
22+
`${programFiles}\\Python${majorMinor}-32\\python.exe`,
23+
`${programFilesX86}\\Python${majorMinor}-32\\python.exe`
2124
)
2225
}
2326

0 commit comments

Comments
 (0)