feature(cloudcmd) add --open: open browser when server started

This commit is contained in:
coderaiser 2016-05-12 20:23:16 +03:00
parent d2cc38dd50
commit 36dcb9a074
7 changed files with 21 additions and 2 deletions

View file

@ -78,9 +78,11 @@ Cloud Commander supports command line parameters:
| `--minify` | enable minification
| `--progress` | show progress of file operations
| `--html-dialogs` | show html dialogs
| `--open` | open web browser when server started
| `--no-server` | do not start server
| `--no-auth` | disable authorization
| `--no-online` | load scripts from local server
| `--no-open` | do not open web browser when server started
| `--no-minify` | disable minification
| `--no-progress` | do not show progress of file operations
| `--no-html-dialogs` | do not use html dialogs
@ -223,6 +225,7 @@ Here is description of options:
"dirStorage" : true, /* store directory listing to localStorage */
"minify" : false, /* minification of js,css,html and img */
"online" : true, /* load js files from cdn or local path */
"open" : false /* open web browser when server started */
"cache" : true, /* add cache-control */
"showKeysPanel" : true, /* show classic panel with buttons of keys */
"port" : 8000, /* http port */
@ -585,3 +588,4 @@ Special Thanks
- config template and style;
- change order of directories and files;
- add ability do not hide path and header when files are scrolling;

View file

@ -30,6 +30,7 @@
'save',
'server',
'online',
'open',
'minify',
'progress',
'progress-of-copying',
@ -41,6 +42,7 @@
port : config('port'),
minify : config('minify'),
online : config('online'),
open : config('open'),
editor : config('editor') || 'edward',
username : config('username'),
root : config('root') || '/',
@ -78,6 +80,7 @@
config('auth', args.auth);
config('online', args.online);
config('open', args.open);
config('minify', args.minify);
config('username', args.username);
config('progress', args.progress);

View file

@ -14,9 +14,11 @@
"--minify ": "enable minification",
"--progress ": "show progress of file operations",
"--html-dialogs ": "use html dialogs",
"--open ": "open web browser when server started",
"--no-server ": "do not start server",
"--no-auth ": "disable authorization",
"--no-online ": "load scripts from local server",
"--no-open ": "do not open web browser when server started",
"--no-minify ": "disable minification",
"--no-progress ": "do not show progress of file operations",
"--no-html-dialogs ": "do not use html dialogs"

View file

@ -12,6 +12,7 @@
"dirStorage": false,
"minify": false,
"online": true,
"open": false,
"cache": true,
"showKeysPanel": true,
"port": 8000,

View file

@ -5,6 +5,7 @@
DIR_SERVER = DIR_LIB + 'server/',
http = require('http'),
opn = require('opn'),
cloudcmd = require(DIR_LIB + 'cloudcmd'),
exit = require(DIR_SERVER + 'exit'),
@ -61,7 +62,8 @@
};
getPort(function(error, port) {
var url = config('ip') || 'localhost' + prefix();
var host = config('ip') || 'localhost';
var url = 'http://' + host + ':' + port + prefix() + '/';
if (error)
return onError(error);
@ -69,7 +71,10 @@
server.listen(port, ip);
server.on('error', onError);
console.log('url: http://%s:%d', url, port);
console.log('url:', url);
if (config('open'))
opn(url);
});
};
})();

View file

@ -37,9 +37,11 @@ programs in browser from any computer, mobile or tablet device.
--minify enable minification
--progress show progress of file operations
--html-dialogs use html dialogs
--open open web browser when server started
--no-auth disable authorization
--no-server do not start server
--no-online load scripts from local server
--no-open do not open web browser when server started
--no-minify disable minification
--no-progress do not show progress of file operations
--no-html-dialogs do not use html dialogs
@ -47,3 +49,4 @@ programs in browser from any computer, mobile or tablet device.
.SH RESOURCES AND DOCUMENTATION
General help using Cloud Commander: <http://cloudcmd.io>

View file

@ -89,6 +89,7 @@
"minify": "~2.0.0",
"minimist": "~1.2.0",
"mollify": "~1.0.0",
"opn": "~4.0.1",
"os-homedir": "~1.0.0",
"package-json": "~2.3.0",
"pipe-io": "~1.2.0",