fix: ensure python path is qouoted on windows #210
This commit is contained in:
+3
-11
@@ -1,27 +1,19 @@
|
||||
const
|
||||
{ normalize } = require('path'),
|
||||
{ Promise, promisify } = require('bluebird'),
|
||||
{ createWriteStream, readFile } = require('fs')
|
||||
{ createWriteStream, readFile } = require('fs'),
|
||||
{ dequote } = require('./util')
|
||||
|
||||
const readFileAsync = promisify(readFile),
|
||||
isWindows = process.platform === 'win32'
|
||||
|
||||
function dequoteStdIn (input) {
|
||||
input = input.trim()
|
||||
if (input.startsWith('\'') && input.endsWith('\'') ||
|
||||
input.startsWith('"') && input.endsWith('"')) {
|
||||
return input.slice(1).slice(0, -1)
|
||||
}
|
||||
return input
|
||||
}
|
||||
|
||||
function getStdIn () {
|
||||
return new Promise((resolve) => {
|
||||
const bundle = []
|
||||
process.stdin.setEncoding('utf-8')
|
||||
process.stdin.on('data', x => bundle.push(x))
|
||||
process.stdin.once('end', () =>
|
||||
resolve(dequoteStdIn(Buffer.concat(bundle).toString()))
|
||||
resolve(dequote(Buffer.concat(bundle).toString()))
|
||||
)
|
||||
process.stdin.resume()
|
||||
})
|
||||
|
||||
+3
-2
@@ -4,7 +4,8 @@ const
|
||||
{ normalizeOptions } = require('./options'),
|
||||
{ readFile, writeFile, createReadStream } = require('fs'),
|
||||
{ spawn } = require('child_process'),
|
||||
{ logger } = require('./logger')
|
||||
{ logger } = require('./logger'),
|
||||
{ dequote } = require('./util')
|
||||
|
||||
const
|
||||
isWindows = process.platform === 'win32',
|
||||
@@ -52,7 +53,7 @@ module.exports.NexeCompiler = class NexeCompiler {
|
||||
return
|
||||
}
|
||||
if (isWindows) {
|
||||
this.env.PATH = this.env.PATH + ';' + normalize(dirname(pythonPath))
|
||||
this.env.PATH = this.env.PATH + ';"' + dequote(normalize(pythonPath)) + '"'
|
||||
} else {
|
||||
this.env.PYTHON = pythonPath
|
||||
}
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
function dequote (input) {
|
||||
input = input.trim()
|
||||
if (input.startsWith('\'') && input.endsWith('\'') ||
|
||||
input.startsWith('"') && input.endsWith('"')) {
|
||||
return input.slice(1).slice(0, -1)
|
||||
}
|
||||
return input
|
||||
}
|
||||
|
||||
module.exports.dequote = dequote
|
||||
Reference in New Issue
Block a user