diff --git a/README.md b/README.md index fe17e57..be14410 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ Also inherits the following from [`child_process.spawn([options])`](https://node * `options.stdio` - Array Child's stdio configuration. Defaults to `['pipe', process.stdout, process.stderr]` * `options.uid` - Number Sets the user identity of the process. * `options.gid` - Number Sets the group identity of the process. +* `options.pythonBridgeScriptPath` - String Path to the `node_python_bridge.py` file. ```javascript var python = pythonBridge({ diff --git a/README.ts.md b/README.ts.md index 676bd76..10365ce 100644 --- a/README.ts.md +++ b/README.ts.md @@ -44,6 +44,7 @@ Also inherits the following from [`child_process.spawn([options])`](https://node * `options.stdio` - Array Child's stdio configuration. Defaults to `['pipe', process.stdout, process.stderr]` * `options.uid` - Number Sets the user identity of the process. * `options.gid` - Number Sets the group identity of the process. +* `options.pythonBridgeScriptPath` - String Path to the `node_python_bridge.py` file. ```javascript const python = pythonBridge({ diff --git a/index.d.ts b/index.d.ts index 126e1f6..2b15ce2 100644 --- a/index.d.ts +++ b/index.d.ts @@ -11,6 +11,8 @@ export interface PythonBridgeOptions { env?: { [key: string]: string | undefined; }; uid?: number; gid?: number; + /** Path to the `node_python_bridge.py` file. */ + pythonBridgeScriptPath?: string } export interface PythonBridge { diff --git a/index.js b/index.js index c19811d..e0459ad 100644 --- a/index.js +++ b/index.js @@ -4,8 +4,6 @@ let Promise = require('bluebird'); let path = require('path'); let child_process = Promise.promisifyAll(require('child_process')); -const PYTHON_BRIDGE_SCRIPT = path.join(__dirname, 'node_python_bridge.py'); - function pythonBridge(opts) { // default options let intepreter = opts && opts.python || 'python'; @@ -19,7 +17,8 @@ function pythonBridge(opts) { }; // create process bridge - let ps = child_process.spawn(intepreter, [PYTHON_BRIDGE_SCRIPT], options); + const pythonBridgeScriptPath = opts.pythonBridgeScriptPath || path.join(__dirname, 'node_python_bridge.py'); + let ps = child_process.spawn(intepreter, [pythonBridgeScriptPath], options); let queue = singleQueue(); function sendPythonCommand(type, enqueue, self) {