Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Editor installed in Chinese path cannot be opened #36

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions packages/launch-editor/guess.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const path = require('path')
const shellQuote = require('shell-quote')
const childProcess = require('child_process')

const iconv = require('iconv-lite')
// Map from full process name to binary that starts the process
// We can't just re-use full process name, because it will spawn a new instance
// of the app every time
Expand Down Expand Up @@ -56,14 +56,19 @@ module.exports = function guessEditor (specifiedEditor) {
}
}
} else if (process.platform === 'win32') {
const output = childProcess
.execSync(
'powershell -NoProfile -Command "Get-CimInstance -Query \\"select executablepath from win32_process where executablepath is not null\\" | % { $_.ExecutablePath }"',
{
stdio: ['pipe', 'pipe', 'ignore']
}
)
.toString()
let output = childProcess
.execSync(
'powershell -NoProfile -Command "Get-CimInstance -Query \\"select executablepath from win32_process where executablepath is not null\\" | % { $_.ExecutablePath }"',
{
stdio: ['pipe', 'pipe', 'ignore']
}
)
// If the system locale is gbk encoding
if(childProcess.execSync(`chcp`, {encoding: `utf8`}).match(/936/)){
output = iconv.decode(output,'gbk')
}else{
output = output.toString();
}
const runningProcesses = output.split('\r\n')
for (let i = 0; i < runningProcesses.length; i++) {
const fullProcessPath = runningProcesses[i].trim()
Expand Down