Skip to content

Commit

Permalink
feature(package) console-io v3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Nov 15, 2016
1 parent 2c024d1 commit 76125f4
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
14 changes: 14 additions & 0 deletions HELP.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,20 @@ Console

For more details see [console hot keys](https://github.com/cloudcmd/console#hot-keys "Console Hot Keys").

Every program executed in `console` has these `environment` variables:

- `ACTIVE_DIR` - directory that contains cursor
- `PASSIVE_DIR` - directory with no cursor
- `CURRENT_NAME` - name of a file under cursor
- `CURRENT_PATH` - path to file under cursor

On Unix you can use it this way:

```sh
~> echo $CURRENT_PATH
/home/coderaiser/cloudcmd/bin/cloudcmd.js
```

Config
---------------
![Config](/img/screen/config.png "Config")
Expand Down
24 changes: 19 additions & 5 deletions lib/client/konsole.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
Konsole.show,
]);

Element = DOM.load({
Element = DOM.load({
name : 'div',
className : 'console'
});
Expand All @@ -48,11 +48,25 @@
return CloudCmd.PREFIX + '/console';
}

function getEnv() {
return {
ACTIVE_DIR: DOM.getCurrentDirPath.bind(DOM),
PASSIVE_DIR: DOM.getNotCurrentDirPath.bind(DOM),
CURRENT_NAME: DOM.getCurrentName.bind(DOM),
CURRENT_PATH: function() {
return DOM.CurrentInfo.path;
}
}
}

function create(callback) {
var prefix = getPrefix(),
socketPath = CloudCmd.PREFIX;
var options = {
env: getEnv(),
prefix: getPrefix(),
socketPath: CloudCmd.PREFIX,
};

Console(Element, prefix, socketPath, function(spawn) {
Console(Element, options, function(spawn) {
spawn.on('connect', exec.with(authCheck, spawn));
Util.exec(callback);
});
Expand All @@ -62,7 +76,7 @@
var command = Console.getPromptText(),
path = DOM.getCurrentDirPath();

command += path;
command += path;
Console.setPromptText(command);
}
});
Expand Down
7 changes: 3 additions & 4 deletions lib/cloudcmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var DIR = __dirname + '/',
ponse = require('ponse'),
mollify = require('mollify'),
restafary = require('restafary'),
webconsole = require('console-io'),
konsole = require('console-io/legacy'),
edward = require('edward/legacy'),
dword = require('dword/legacy'),
deepword = require('deepword/legacy'),
Expand Down Expand Up @@ -147,9 +147,8 @@ function listen(prefix, socket) {
authCheck: authCheck
});

config('console') && webconsole({
config('console') && konsole.listen(socket, {
prefix: prefix + '/console',
socket: socket,
authCheck: authCheck
});
}
Expand All @@ -170,7 +169,7 @@ function cloudcmd(prefix) {
}),

funcs = [
webconsole.middle({
konsole({
prefix: prefix + '/console',
minify: isMinify,
online: isOnline
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"apart": "^1.0.1",
"chalk": "^1.1.0",
"checkup": "^1.3.0",
"console-io": "^2.7.1",
"console-io": "^3.0.0",
"copymitter": "^1.8.0",
"criton": "^1.0.0",
"deepword": "^1.1.2",
Expand Down

0 comments on commit 76125f4

Please sign in to comment.