diff --git a/Readme.md b/Readme.md index c11c0a6..d2196a5 100644 --- a/Readme.md +++ b/Readme.md @@ -43,6 +43,12 @@ Make the current folder available on `:12345` on the local network: cute-files --port 12345 ``` +Make the current folder available on `:12345` on the local network and open browser: + +```bash +cute-files --port 12345 --launch +``` + ### Notes Files starting with a dot are assumed to be private and are not served. \ No newline at end of file diff --git a/cute-files.js b/cute-files.js index 147c0ac..75fa831 100755 --- a/cute-files.js +++ b/cute-files.js @@ -15,6 +15,7 @@ var program = require('commander'); program .version(pkg.version) .option('-p, --port ', 'Port on which to listen to (defaults to 3000)', parseInt) + .option('-l, --launch', 'Launch default web browser to local server') .parse(process.argv); var port = program.port || 3000; @@ -59,4 +60,10 @@ app.get('/scan', function(req,res){ app.listen(port); -console.log('Cute files is running on port ' + port); \ No newline at end of file +console.log('Cute files is running on port ' + port); + +// opening users browser +var open = require('open'); + +if(program.launch) + open('http://localhost:' + port); \ No newline at end of file diff --git a/package.json b/package.json index 25f3c44..30dbb07 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,8 @@ "dependencies": { "commander": "^2.3.0", "content-disposition": "^0.3.0", - "express": "^4.9.4" + "express": "^4.9.4", + "open": "0.0.5" }, "preferGlobal": true, "bin": {