Skip to content

Commit

Permalink
refactor: move open and ignored path logic to serve module
Browse files Browse the repository at this point in the history
  • Loading branch information
w33ble committed Apr 20, 2014
1 parent 8beed14 commit adb182c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion bin/lute.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ var isInt = require('../lib/util/isInt');
var serve = require('../lib/serve');
var port = (argv.p && isInt(argv.p)) ? argv.p : 8080;

serve(port, (argv._.indexOf('open') !== -1), argv);
serve(port, argv);
11 changes: 9 additions & 2 deletions lib/serve/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@ var createLiveReload = require('./createLiveReload');
var createServer = require('./createServer');
var watch = require('./watch');

module.exports = function(port, open, argv) {
module.exports = function(port, argv) {
var open = (argv._.indexOf('open') !== -1);
var watchPaths = ["./**/*", "!./node_modules/**/*"];
var ignorePaths = (argv.i) ? argv.i.split(',') : [];

for(var i=0; i<ignorePaths.length; i++) {
watchPaths.push("!./" + ignorePaths[i] + '/**/*');
}

createLiveReload(function(err, liveReload, lrPort){
createServer(port, lrPort, open, function(err, server){
watch(liveReload, argv);
watch(liveReload, watchPaths);
});
});

Expand Down
8 changes: 1 addition & 7 deletions lib/serve/watch.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
var gulp = require('gulp');
var gutil = require('gulp-util');

module.exports = function(liveReload, argv) {

var paths = ["./**/*", "!./node_modules/**/*"];
var ignorePaths = (argv.i) ? argv.i.split(',') : [];
for(var i=0; i<ignorePaths.length; i++) {
paths.push("!./" + ignorePaths[i] + '/**/*');
}
module.exports = function(liveReload, paths) {

gulp.watch(paths, function(evt){

Expand Down

0 comments on commit adb182c

Please sign in to comment.