diff --git a/lib/index.js b/lib/index.js index 1f0cca3..8cedfc2 100644 --- a/lib/index.js +++ b/lib/index.js @@ -20,8 +20,13 @@ var bufferStream = function(stream){ var execute = function ( path, script, vars, cb ) { if ( cb === undefined ) cb = vars; + if ( typeof path !== 'undefined') { + opts = { cwd: dirname(path) } + } else { + opts = {} + } - var cp = spawn("osascript", ["-ss", "-"], { cwd: dirname(path) }); + var cp = spawn("osascript", ["-ss", "-"], opts); var outBuffer = bufferStream(cp.stdout); var errBuffer = bufferStream(cp.stderr);