From 1993782e32b6ac09b08c21b8acf457c24fe4d523 Mon Sep 17 00:00:00 2001 From: brunosimon Date: Sun, 20 Nov 2016 23:14:06 +0100 Subject: [PATCH] :sparkles: Open project in default browser --- bin/index.js | 2 +- package.json | 1 + site/site.class.js | 10 +++++++++- watcher/watcher.class.js | 16 ++++++++-------- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/bin/index.js b/bin/index.js index 5cb6b47..a55fece 100644 --- a/bin/index.js +++ b/bin/index.js @@ -3,4 +3,4 @@ 'use strict' let Keppler = require( './keppler.class.js' ), - keppler = new Keppler(); + keppler = new Keppler() diff --git a/package.json b/package.json index 436c411..9f23ef4 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "ip": "^1.1.3", "mime": "^1.3.4", "minimatch": "^3.0.3", + "opener": "^1.4.2", "pug": "^2.0.0-beta4", "slug": "^0.9.1", "socket.io": "^1.4.6", diff --git a/site/site.class.js b/site/site.class.js index 1b9a4c7..04ae4f0 100644 --- a/site/site.class.js +++ b/site/site.class.js @@ -10,7 +10,8 @@ let express = require( 'express' ), util = require( 'util' ), path = require( 'path' ), Projects = require( './models/projects.class.js' ), - fs = require( 'fs' ) + fs = require( 'fs' ), + opener = require( 'opener' ) /** * Site class @@ -258,6 +259,13 @@ class Site { project = this.projects.create_project( data.name ) + let url = this.options.domain + '/project/' + project.slug + + console.log( 'server'.green.bold + ' - ' + url .cyan ) + + // Open in browser + opener( url ) + // Debug if( this.options.debug ) { diff --git a/watcher/watcher.class.js b/watcher/watcher.class.js index 0ed6ce5..e044fd3 100644 --- a/watcher/watcher.class.js +++ b/watcher/watcher.class.js @@ -96,13 +96,13 @@ class Watcher mime_type = mime.lookup( relative_path ), file = {} - file.path = relative_path; - file.can_read = true; + file.path = relative_path + file.can_read = true // Test mime type if( mime_type.match(/^(audio)|(video)|(image)/) ) { - file.can_read = false; + file.can_read = false } // Test exclusion @@ -114,7 +114,7 @@ class Watcher // Match excluded path if( minimatch( relative_path, _exclude ) ) - return; + return } // Retrieve stats @@ -150,13 +150,13 @@ class Watcher mime_type = mime.lookup( relative_path ), file = {} - file.path = relative_path; - file.can_read = true; + file.path = relative_path + file.can_read = true // Test mime type if( mime_type.match(/^(audio)|(video)|(image)/) ) { - file.can_read = false; + file.can_read = false } // Test exclusion @@ -168,7 +168,7 @@ class Watcher // Match excluded path if( minimatch( relative_path, _exclude ) ) - return; + return } // Retrieve stats