diff --git a/src/cli.js b/src/cli.js index f66b4cf..50e2e62 100644 --- a/src/cli.js +++ b/src/cli.js @@ -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() }) diff --git a/src/compiler.js b/src/compiler.js index aa1f978..325bde3 100644 --- a/src/compiler.js +++ b/src/compiler.js @@ -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 } diff --git a/src/util.js b/src/util.js new file mode 100644 index 0000000..7375f45 --- /dev/null +++ b/src/util.js @@ -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 \ No newline at end of file