From e15be119674f8bac920cb54d49b0b201e2fb5077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8A=A0=E7=BC=AA?= Date: Thu, 25 Sep 2014 12:25:45 +0800 Subject: [PATCH 1/3] accept server instance as an option, so it may intergrate with other application --- lib/flo.js | 1 + lib/server.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/flo.js b/lib/flo.js index b91594b..d884f7d 100644 --- a/lib/flo.js +++ b/lib/flo.js @@ -74,6 +74,7 @@ function Flo(dir, options, callback) { this.realpathdir = fs.realpathSync(dir); this.resolver = callback; this.server = new Server({ + server : options.server || null, port: options.port, host: options.host, log: logger(options.verbose, 'Server') diff --git a/lib/server.js b/lib/server.js index 232d371..d5cbdea 100644 --- a/lib/server.js +++ b/lib/server.js @@ -24,11 +24,11 @@ module.exports = Server; function Server(options) { this.log = options.log || function() {}; - this.httpServer = http.createServer(function(req, res) { + this.httpServer = options.server || http.createServer(function(req, res) { res.writeHead(404); res.end(); }); - this.httpServer.listen(options.port); + !options.server && this.httpServer.listen(options.port); this.wsServer = new WSS({ httpServer: this.httpServer, autoAcceptConnections: false From 42db69aea51cb59334894252322ad7a75739d399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8A=A0=E7=BC=AA?= Date: Thu, 25 Sep 2014 12:39:37 +0800 Subject: [PATCH 2/3] modify package information --- .gitignore | 1 + README.md | 26 ++++++++++++++++++++++++++ package.json | 4 ++-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index fd4f2b0..22d59e5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules .DS_Store +.idea diff --git a/README.md b/README.md index 1391d18..2385d0e 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,32 @@ var server = flo( ); ``` +or integrate with exist server instance: + +``` +var express = require('express'), + app = express(), + http = require("http"), + server = http.createServer(app), + fs = require('fs') + +flo(PATH_TO_DIR,{ + server:server, + glob:[ + '**/*.css', + '**/*.html', + '**/*.jade' + ]},function( filePath, callback){ + callback({ + resourceURL : resourceURL, + contents : fs.readFileSync(path.join(root,filePath)), + update : function( _window,_resourceURL){ + } + }) + } + }) +``` + `flo` takes the following arguments. * `sourceDirToWatch`: absolute or relative path to the directory to watch that contains the source code that will be built. diff --git a/package.json b/package.json index e6d1bde..dc626f5 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { - "name": "fb-flo", + "name": "fb-flo-extra", "version": "0.3.1", "description": "Modify running web apps without reloading", "repository": { "type": "git", - "url": "git@github.com:facebook/fb-flo.git" + "url": "git@github.com:sskyy/fb-flo.git" }, "main": "index.js", "scripts": { From 3367b008fd152423a459529a7943499e05c65279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8A=A0=E7=BC=AA?= Date: Sun, 28 Sep 2014 11:40:07 +0800 Subject: [PATCH 3/3] change sane to gaze --- lib/flo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/flo.js b/lib/flo.js index d884f7d..9a8a831 100644 --- a/lib/flo.js +++ b/lib/flo.js @@ -68,7 +68,7 @@ var DELAY = 200; * @private */ -function Flo(dir, options, callback) { +function Flo( dir, options, callback) { this.log = logger(options.verbose, 'Flo'); this.dir = dir; this.realpathdir = fs.realpathSync(dir);