diff --git a/plugins/c9.ide.run.debug.ikpdb/ikpdb.js b/plugins/c9.ide.run.debug.ikpdb/ikpdb.js index 812baec6..ac05c5fd 100644 --- a/plugins/c9.ide.run.debug.ikpdb/ikpdb.js +++ b/plugins/c9.ide.run.debug.ikpdb/ikpdb.js @@ -542,8 +542,8 @@ define(function(require, exports, module) { function getProxySource(process) { return PROXY.replace(/\/\/.*/g, "") .replace(/[\n\r]/g, "") - .replace(/\{DEBUGGED_PROCESS_PORT\}/, (process.runner[0] || process.runner).debugport) - .replace(/\{DEBUGGED_PROCESS_HOST\}/, (process.runner[0] || process.runner).debughost || "127.0.0.1"); + .replace(/\{DEBUGGED_PROCESS_PORT\}/, process.runner.debugport) + .replace(/\{DEBUGGED_PROCESS_HOST\}/, process.runner.debughost || "127.0.0.1"); } diff --git a/plugins/c9.ide.run.debug.xdebug/xdebug.js b/plugins/c9.ide.run.debug.xdebug/xdebug.js index ee764342..5dc686fb 100644 --- a/plugins/c9.ide.run.debug.xdebug/xdebug.js +++ b/plugins/c9.ide.run.debug.xdebug/xdebug.js @@ -455,8 +455,8 @@ define(function(require, exports, module) { return PROXY .replace(/\/\/.*/g, "") .replace(/[\n\r]/g, "") - .replace(/\{HOST\}/, process.runner[0].debughost || "") - .replace(/\{PORT\}/, process.runner[0].debugport); + .replace(/\{HOST\}/, process.runner.debughost || "") + .replace(/\{PORT\}/, process.runner.debugport); } function setBreakpoints(breakpoints, callback) { diff --git a/plugins/c9.ide.run.debug/debuggers/gdb/gdbdebugger.js b/plugins/c9.ide.run.debug/debuggers/gdb/gdbdebugger.js index e50490d8..8ff0f688 100755 --- a/plugins/c9.ide.run.debug/debuggers/gdb/gdbdebugger.js +++ b/plugins/c9.ide.run.debug/debuggers/gdb/gdbdebugger.js @@ -232,9 +232,9 @@ define(function(require, exports, module) { var socketpath = Path.join(c9.home, "/.c9/gdbdebugger.socket"); return { source: null, - socketpath: process.runner[0].socketpath || socketpath, - retryInverval: process.runner[0].retryInterval || 300, - retries: process.runner[0].retryCount || 1000 + socketpath: process.runner.socketpath || socketpath, + retryInverval: process.runner.retryInterval || 300, + retries: process.runner.retryCount || 1000 }; } diff --git a/plugins/c9.ide.run.debug/debuggers/v8/v8debugger.js b/plugins/c9.ide.run.debug/debuggers/v8/v8debugger.js index 1210772e..55950041 100644 --- a/plugins/c9.ide.run.debug/debuggers/v8/v8debugger.js +++ b/plugins/c9.ide.run.debug/debuggers/v8/v8debugger.js @@ -605,7 +605,7 @@ define(function(require, exports, module) { return debug.proxySource .replace(/\/\/.*/g, "") .replace(/[\n\r]/g, "") - .replace(/\{PORT\}/, (process.runner[0] || process.runner).debugport); + .replace(/\{PORT\}/, process.runner.debugport); } function attach(s, reconnect, callback) { diff --git a/plugins/c9.ide.run/run.js b/plugins/c9.ide.run/run.js index e288b88b..3987e475 100644 --- a/plugins/c9.ide.run/run.js +++ b/plugins/c9.ide.run/run.js @@ -134,7 +134,7 @@ define(function(require, module, exports) { return re.test(file); } } - else if (selector instanceof Array) { + else if (Array.isArray(selector)) { return selector.some(function(n) { return matchSelector(n, path); }); @@ -213,12 +213,11 @@ define(function(require, module, exports) { if (!name) name = "output"; - (options instanceof Array ? options : [options]).forEach(function(a) { - a.relPath = a.path; - a.path = makeAbsolutePath(a.path); - a.path = c9.toExternalPath(a.path, "/"); - a.cwd = makeAbsolutePath(a.cwd); - }); + + options.relPath = options.path; + options.path = makeAbsolutePath(options.path); + options.path = c9.toExternalPath(options.path, "/"); + options.cwd = makeAbsolutePath(options.cwd); var proc = new Process(name, runner, options, callback); processes.push(proc); @@ -297,67 +296,55 @@ define(function(require, module, exports) { emit("starting"); - if (!(runner instanceof Array)) - runner = [runner]; - - if (!(options instanceof Array)) - options = [options]; - if (deferred) return setTimeout(callback); - cmd = runner.map(function(runner, idx) { - var cmd = ""; - - // Display a message prior to running the command - if (runner.info) - cmd += "printf '\\033[1m" + runner.info.replace(/%/g, "%%") + "\\033[m\n' ; "; - - // Set the PATH variable if needed - if (runner.path) - cmd += "export PATH=" + runner.path + " ; "; - - var env = util.extend({}, options[idx].env, runner.env); - for (var name in env) { - // HACK: old configurations used double quoting of environment values; - // let's support such nastiness for now - var value = /^["'].*["']$/.test(env[name]) - ? env[name] - : env[name].replace(/'/g, "'\\''"); - cmd += "export " + name + "='" + value + "'; "; - } - - // Open a pty session with tmux on the output buffer - if (runner.script) { - // Replace variables - cmd = insertVariables(cmd, options[idx]); - cmd += typeof runner.script == "string" ? runner.script : runner.script.join("\n"); - var matches = cmd.match(/\$[\w\-]+/g) || []; - var seen = {}; - cmd = matches.map(function(key) { - if (seen[key]) - return ""; - seen[key] = 1; - var val = getVariable(key.slice(1), options[idx]); - if (val == key) - return ""; - return key.slice(1) + "=" + bashQuote([val]) + ";"; - }).join("") + "\n" + cmd; - } else { - // @todo add argument escaping - cmd += bashQuote(options[idx].debug && runner["cmd-debug"] || runner.cmd); - // Replace variables - cmd = insertVariables(cmd, options[idx]); - } - - return cmd; - }).join("; "); + var cmd = ""; - // The rest of the options are singular. Choosing the first option object for this. - options = options[0]; + // Display a message prior to running the command + if (runner.info) + cmd += "printf '\\033[1m" + runner.info.replace(/%/g, "%%") + "\\033[m\n' ; "; + + // Set the PATH variable if needed + if (runner.path) + cmd += "export PATH=" + runner.path + " ; "; + + var env = util.extend({}, options.env, runner.env); + for (var name in env) { + // HACK: old configurations used double quoting of environment values; + // let's support such nastiness for now + var value = /^["'].*["']$/.test(env[name]) + ? env[name] + : env[name].replace(/'/g, "'\\''"); + cmd += "export " + name + "='" + value + "'; "; + } + + // Open a pty session with tmux on the output buffer + if (runner.script) { + // Replace variables + cmd = insertVariables(cmd, options); + cmd += typeof runner.script == "string" ? runner.script : runner.script.join("\n"); + var matches = cmd.match(/\$[\w\-]+/g) || []; + var seen = { args: true }; + cmd = matches.map(function(key) { + if (seen[key]) + return ""; + seen[key] = 1; + var val = getVariable(key.slice(1), options); + if (val == key) + return ""; + return key.slice(1) + "=" + bashQuote([val]) + ";"; + }).join("") + "\n" + cmd; + } else { + // @todo add argument escaping + cmd += bashQuote(options.debug && runner["cmd-debug"] || runner.cmd); + // Replace variables + cmd = insertVariables(cmd, options); + } - var cwd = options.cwd || runner[0].working_dir + var cwd = options.cwd || runner.working_dir || options.path && dirname(c9.toInternalPath(options.path)) || "/"; + cwd = insertVariables(cwd, options); console.log(cmd); // Execute run.sh @@ -595,7 +582,7 @@ define(function(require, module, exports) { if (c9.platform === "win32") return proc.execFile("kill", { args: [pid]}, done); - var runCfg = runner && runner[0]; + var runCfg = runner; if (runCfg && runCfg.cmdStop) { return proc.execFile("bash", { args: ["-c", bashQuote(runCfg.cmdStop)]}, done); @@ -605,9 +592,9 @@ define(function(require, module, exports) { if (runCfg && runCfg.cmdCleanup) { proc.execFile("bash", { args: ["-c", bashQuote(runCfg.cmdCleanup)]}, done); } - else if (meta.debug && runner && runner[0].debugport) { - var kill = "kill -9 $(lsof -i:" + runner[0].debugport + " -t);" - + "if sudo -n true; then sudo kill -9 $(sudo lsof -i:" + runner[0].debugport + " -t); fi"; + else if (meta.debug && runner && runner.debugport) { + var kill = "kill -9 $(lsof -i:" + runner.debugport + " -t);" + + "if sudo -n true; then sudo kill -9 $(sudo lsof -i:" + runner.debugport + " -t); fi"; proc.execFile("sh", { args: ["-c", kill]}, done); } else { diff --git a/plugins/c9.ide.run/run_analytics.js b/plugins/c9.ide.run/run_analytics.js index 241d14e5..740de268 100644 --- a/plugins/c9.ide.run/run_analytics.js +++ b/plugins/c9.ide.run/run_analytics.js @@ -24,7 +24,7 @@ define(function(require, exports, module) { if (!e.process.runner) return; // Gets called whenever one creates a new process - var runner = e.process.runner[0]; + var runner = e.process.runner; var builtin = runner.$builtin; var runnerName = runner.caption; var cmdLength = runner.cmd && runner.cmd.length;