kopia lustrzana https://github.com/c9/core
Merge remote-tracking branch 'origin/master' into refactor-clone-api
commit
79adede130
|
@ -80,6 +80,10 @@ return [
|
||||||
packagePath: "./c9.cli.open/open",
|
packagePath: "./c9.cli.open/open",
|
||||||
platform: process.platform
|
platform: process.platform
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
packagePath: "./c9.cli.exec/exec",
|
||||||
|
platform: process.platform
|
||||||
|
},
|
||||||
{
|
{
|
||||||
packagePath: "./c9.cli.open/restart",
|
packagePath: "./c9.cli.open/restart",
|
||||||
platform: process.platform
|
platform: process.platform
|
||||||
|
|
|
@ -1827,9 +1827,11 @@ module.exports = function setup(fsOptions) {
|
||||||
}
|
}
|
||||||
else if (options.command) {
|
else if (options.command) {
|
||||||
args.push(BASH + " -l -c '"
|
args.push(BASH + " -l -c '"
|
||||||
+ options.command.replace(/'/g, "'\\''")
|
+ (
|
||||||
+ '; printf "\\e[01;30m\\n\\nProcess exited with code: $?\\e[0m\\n"'
|
'trap \'printf "\\e[01;30m\\n\\nProcess exited with code: $?\\e[0m\\n"\' EXIT\n'
|
||||||
+ "; sleep 0.1;'");
|
+ options.command
|
||||||
|
).replace(/'/g, "'\\''")
|
||||||
|
+ "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
args.push(
|
args.push(
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "c9",
|
"name": "c9",
|
||||||
"description": "New Cloud9 Client",
|
"description": "New Cloud9 Client",
|
||||||
"version": "3.1.1876",
|
"version": "3.1.1888",
|
||||||
"author": "Ajax.org B.V. <info@ajax.org>",
|
"author": "Ajax.org B.V. <info@ajax.org>",
|
||||||
"private": true,
|
"private": true,
|
||||||
"main": "bin/c9",
|
"main": "bin/c9",
|
||||||
|
@ -72,7 +72,7 @@
|
||||||
"c9.ide.find": "#e33fbaed2f",
|
"c9.ide.find": "#e33fbaed2f",
|
||||||
"c9.ide.find.infiles": "#c0a13737ef",
|
"c9.ide.find.infiles": "#c0a13737ef",
|
||||||
"c9.ide.find.replace": "#8cbce45290",
|
"c9.ide.find.replace": "#8cbce45290",
|
||||||
"c9.ide.run.debug": "#286975f644",
|
"c9.ide.run.debug": "#7d6da73fc7",
|
||||||
"c9.automate": "#47e2c429c9",
|
"c9.automate": "#47e2c429c9",
|
||||||
"c9.ide.ace.emmet": "#6dc4585e02",
|
"c9.ide.ace.emmet": "#6dc4585e02",
|
||||||
"c9.ide.ace.gotoline": "#a8ff07c8f4",
|
"c9.ide.ace.gotoline": "#a8ff07c8f4",
|
||||||
|
@ -118,6 +118,6 @@
|
||||||
"c9.ide.undo": "#b028bcb4d5",
|
"c9.ide.undo": "#b028bcb4d5",
|
||||||
"c9.ide.upload": "#0bd010d3dc",
|
"c9.ide.upload": "#0bd010d3dc",
|
||||||
"c9.ide.welcome": "#5b86c44e92",
|
"c9.ide.welcome": "#5b86c44e92",
|
||||||
"c9.ide.guide": "#d2e406b5e3"
|
"c9.ide.guide": "#8ab966f344"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,7 +2,7 @@
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
main.consumes = [
|
main.consumes = [
|
||||||
"Plugin", "bridge", "tabManager", "panels", "tree.favorites", "tree",
|
"Plugin", "bridge", "tabManager", "panels", "tree.favorites", "tree",
|
||||||
"fs", "preferences", "settings", "c9"
|
"fs", "preferences", "settings", "c9", "commands"
|
||||||
];
|
];
|
||||||
main.provides = ["bridge.commands"];
|
main.provides = ["bridge.commands"];
|
||||||
return main;
|
return main;
|
||||||
|
@ -18,6 +18,7 @@ define(function(require, exports, module) {
|
||||||
var fs = imports.fs;
|
var fs = imports.fs;
|
||||||
var c9 = imports.c9;
|
var c9 = imports.c9;
|
||||||
var prefs = imports.preferences;
|
var prefs = imports.preferences;
|
||||||
|
var commands = imports.commands;
|
||||||
|
|
||||||
var async = require("async");
|
var async = require("async");
|
||||||
|
|
||||||
|
@ -36,6 +37,9 @@ define(function(require, exports, module) {
|
||||||
case "open":
|
case "open":
|
||||||
open(message, e.respond);
|
open(message, e.respond);
|
||||||
break;
|
break;
|
||||||
|
case "exec":
|
||||||
|
exec(message, e.respond);
|
||||||
|
break;
|
||||||
case "pipe":
|
case "pipe":
|
||||||
createPipe(message, e.respond);
|
createPipe(message, e.respond);
|
||||||
break;
|
break;
|
||||||
|
@ -173,6 +177,12 @@ define(function(require, exports, module) {
|
||||||
callback(null, true);
|
callback(null, true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function exec(message, callback) {
|
||||||
|
var result = commands.exec(message.command, message.args);
|
||||||
|
var err = result ? null : "command failed";
|
||||||
|
callback(err, result);
|
||||||
|
}
|
||||||
|
|
||||||
/***** Lifecycle *****/
|
/***** Lifecycle *****/
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,92 @@
|
||||||
|
define(function(require, exports, module) {
|
||||||
|
main.consumes = ["Plugin", "cli_commands", "bridge.client"];
|
||||||
|
main.provides = ["exec"];
|
||||||
|
return main;
|
||||||
|
|
||||||
|
function main(options, imports, register) {
|
||||||
|
var Plugin = imports.Plugin;
|
||||||
|
var cmd = imports.cli_commands;
|
||||||
|
var bridge = imports["bridge.client"];
|
||||||
|
|
||||||
|
/***** Initialization *****/
|
||||||
|
|
||||||
|
var plugin = new Plugin("Ajax.org", main.consumes);
|
||||||
|
// var emit = plugin.getEmitter();
|
||||||
|
|
||||||
|
var loaded;
|
||||||
|
function load(){
|
||||||
|
if (loaded) return;
|
||||||
|
loaded = true;
|
||||||
|
|
||||||
|
cmd.addCommand({
|
||||||
|
name: "exec",
|
||||||
|
info: " Executes remote c9 commands.",
|
||||||
|
usage: "<command> [argument 1] [argument 2] ... [argument n]",
|
||||||
|
check: function(argv) {
|
||||||
|
if (argv._.length < 2)
|
||||||
|
throw new Error("Missing command");
|
||||||
|
},
|
||||||
|
options: {},
|
||||||
|
exec: function(argv) {
|
||||||
|
exec(
|
||||||
|
argv._[1],
|
||||||
|
argv._.slice(2),
|
||||||
|
function(){});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** Methods *****/
|
||||||
|
|
||||||
|
function exec(command, args, callback) {
|
||||||
|
args.unshift(process.cwd());
|
||||||
|
var message = {
|
||||||
|
type: "exec",
|
||||||
|
command: command,
|
||||||
|
args: args
|
||||||
|
};
|
||||||
|
|
||||||
|
bridge.send(message, function cb(err, response) {
|
||||||
|
if (err) {
|
||||||
|
console.log(err.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response !== true)
|
||||||
|
console.log("Could not execute", command);
|
||||||
|
|
||||||
|
process.exit(); // I don't get why this is needed
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** Lifecycle *****/
|
||||||
|
|
||||||
|
plugin.on("load", function(){
|
||||||
|
load();
|
||||||
|
});
|
||||||
|
plugin.on("enable", function(){
|
||||||
|
|
||||||
|
});
|
||||||
|
plugin.on("disable", function(){
|
||||||
|
|
||||||
|
});
|
||||||
|
plugin.on("unload", function(){
|
||||||
|
loaded = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
/***** Register and define API *****/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds or lists files and/or lines based on their filename or contents
|
||||||
|
**/
|
||||||
|
plugin.freezePublicAPI({
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
exec: exec
|
||||||
|
});
|
||||||
|
|
||||||
|
register(null, {
|
||||||
|
exec: plugin
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
|
@ -470,7 +470,7 @@ Terminal.prototype.writeInternal = function(data) {//TODO optimize lines
|
||||||
if (!this.insertMode)
|
if (!this.insertMode)
|
||||||
line[this.x] = [this.curAttr, ch];
|
line[this.x] = [this.curAttr, ch];
|
||||||
else
|
else
|
||||||
line[insertY].splice(this.x, 0, [this.curAttr, ch]);
|
line.splice(this.x, 0, [this.curAttr, ch]);
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
if (this.x > 0) this.x--;
|
if (this.x > 0) this.x--;
|
||||||
|
@ -481,7 +481,7 @@ Terminal.prototype.writeInternal = function(data) {//TODO optimize lines
|
||||||
line[this.x] = [this.curAttr, ch];
|
line[this.x] = [this.curAttr, ch];
|
||||||
line[this.x + 1] = [this.curAttr, "\x00"];
|
line[this.x + 1] = [this.curAttr, "\x00"];
|
||||||
} else {
|
} else {
|
||||||
line[insertY].splice(this.x, 0, [this.curAttr, ch], [this.curAttr, ""]);
|
line.splice(this.x, 0, [this.curAttr, ch], [this.curAttr, ""]);
|
||||||
}
|
}
|
||||||
this.x++;
|
this.x++;
|
||||||
break;
|
break;
|
||||||
|
|
Ładowanie…
Reference in New Issue