Merge remote-tracking branch 'origin/master' into refactor-clone-api

pull/284/head
Matthijs van Henten 2016-03-22 08:58:27 +00:00
commit 79adede130
6 zmienionych plików z 117 dodań i 9 usunięć

Wyświetl plik

@ -80,6 +80,10 @@ return [
packagePath: "./c9.cli.open/open",
platform: process.platform
},
{
packagePath: "./c9.cli.exec/exec",
platform: process.platform
},
{
packagePath: "./c9.cli.open/restart",
platform: process.platform

8
node_modules/vfs-local/localfs.js wygenerowano vendored
Wyświetl plik

@ -1827,9 +1827,11 @@ module.exports = function setup(fsOptions) {
}
else if (options.command) {
args.push(BASH + " -l -c '"
+ options.command.replace(/'/g, "'\\''")
+ '; printf "\\e[01;30m\\n\\nProcess exited with code: $?\\e[0m\\n"'
+ "; sleep 0.1;'");
+ (
'trap \'printf "\\e[01;30m\\n\\nProcess exited with code: $?\\e[0m\\n"\' EXIT\n'
+ options.command
).replace(/'/g, "'\\''")
+ "'");
}
args.push(

Wyświetl plik

@ -1,7 +1,7 @@
{
"name": "c9",
"description": "New Cloud9 Client",
"version": "3.1.1876",
"version": "3.1.1888",
"author": "Ajax.org B.V. <info@ajax.org>",
"private": true,
"main": "bin/c9",
@ -72,7 +72,7 @@
"c9.ide.find": "#e33fbaed2f",
"c9.ide.find.infiles": "#c0a13737ef",
"c9.ide.find.replace": "#8cbce45290",
"c9.ide.run.debug": "#286975f644",
"c9.ide.run.debug": "#7d6da73fc7",
"c9.automate": "#47e2c429c9",
"c9.ide.ace.emmet": "#6dc4585e02",
"c9.ide.ace.gotoline": "#a8ff07c8f4",
@ -118,6 +118,6 @@
"c9.ide.undo": "#b028bcb4d5",
"c9.ide.upload": "#0bd010d3dc",
"c9.ide.welcome": "#5b86c44e92",
"c9.ide.guide": "#d2e406b5e3"
"c9.ide.guide": "#8ab966f344"
}
}

Wyświetl plik

@ -2,7 +2,7 @@
define(function(require, exports, module) {
main.consumes = [
"Plugin", "bridge", "tabManager", "panels", "tree.favorites", "tree",
"fs", "preferences", "settings", "c9"
"fs", "preferences", "settings", "c9", "commands"
];
main.provides = ["bridge.commands"];
return main;
@ -18,6 +18,7 @@ define(function(require, exports, module) {
var fs = imports.fs;
var c9 = imports.c9;
var prefs = imports.preferences;
var commands = imports.commands;
var async = require("async");
@ -36,6 +37,9 @@ define(function(require, exports, module) {
case "open":
open(message, e.respond);
break;
case "exec":
exec(message, e.respond);
break;
case "pipe":
createPipe(message, e.respond);
break;
@ -173,6 +177,12 @@ define(function(require, exports, module) {
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 *****/

Wyświetl plik

@ -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
});
}
});

Wyświetl plik

@ -470,7 +470,7 @@ Terminal.prototype.writeInternal = function(data) {//TODO optimize lines
if (!this.insertMode)
line[this.x] = [this.curAttr, ch];
else
line[insertY].splice(this.x, 0, [this.curAttr, ch]);
line.splice(this.x, 0, [this.curAttr, ch]);
break;
case 0:
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 + 1] = [this.curAttr, "\x00"];
} else {
line[insertY].splice(this.x, 0, [this.curAttr, ch], [this.curAttr, ""]);
line.splice(this.x, 0, [this.curAttr, ch], [this.curAttr, ""]);
}
this.x++;
break;