Skip to content

Commit cf769d1

Browse files
authored
Merge pull request #173 from richbalmer/master
Honour defaultOptions.pythonPath in checkSyntax
2 parents da77217 + 1338e54 commit cf769d1

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,12 @@ export class PythonShell extends EventEmitter{
244244
*/
245245
static async checkSyntaxFile(filePath:string){
246246

247-
let compileCommand = `${this.defaultPythonPath} -m py_compile ${filePath}`
247+
let pythonPath:string;
248+
if (this.defaultOptions.pythonPath) {
249+
pythonPath = this.defaultOptions.pythonPath;
250+
} else pythonPath = this.defaultPythonPath;
251+
252+
let compileCommand = `${pythonPath} -m py_compile ${filePath}`
248253

249254
return new Promise<string>((resolve, reject) => {
250255
exec(compileCommand, (error, stdout, stderr) => {

test/test-python-shell.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ describe('PythonShell', function () {
8080
done();
8181
})
8282
})
83+
84+
it('should honour defaultOptions.pythonPath', function ( done) {
85+
PythonShell.defaultOptions = {
86+
pythonPath: "/usr/bin/python2.7"
87+
};
88+
PythonShell.checkSyntax("print 1").then(()=>{
89+
done();
90+
})
91+
})
8392
})
8493

8594
// #158 these tests are failing on appveyor windows node 8/10 python 2/3

0 commit comments

Comments
 (0)