fix: ensure python path is qouoted on windows #210

This commit is contained in:
calebboyd
2017-04-09 23:01:31 -05:00
parent 40f1e6056f
commit b10b3d268d
3 changed files with 16 additions and 13 deletions
+3 -11
View File
@@ -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
View File
@@ -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
View File
@@ -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