browser-sync
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -12,3 +12,3 @@ | ||
// }, | ||
// proxy: "swoon.static/store-home.php", | ||
proxy: "meandem.dev", | ||
ghostMode: { | ||
@@ -19,11 +19,9 @@ forms: { | ||
}, | ||
// tunnel: true, | ||
ports: { | ||
min: 4000, | ||
max: 4003 | ||
}, | ||
files: files, | ||
tunnel: true, | ||
port: 8080, | ||
open: true, | ||
logConnections: false, | ||
minify: true, | ||
// host: , | ||
logLevel: "debug", | ||
notify: true, | ||
@@ -40,7 +38,2 @@ xip: false, | ||
var bs = browserSync.init(files, options, function (err, bs) { | ||
console.timeEnd("init"); | ||
// setTimeout(function () { | ||
// browserSync.notify("5 Seconds have passed!"); | ||
// }, 5000); | ||
}); | ||
var bs = browserSync.init(options, function (err, bs) {}); |
@@ -28,2 +28,3 @@ "use strict"; | ||
css: "test/fixtures/css", | ||
cssGlob: "test/fixtures/assets/*.css", | ||
html: "test/fixtures/*.html" | ||
@@ -57,7 +58,13 @@ }; | ||
}); | ||
setTimeout(function () { | ||
browserSync.exit(); | ||
}, 3000); | ||
}); | ||
/** | ||
* Start BrowserSync | ||
*/ | ||
gulp.task("browser-sync-css", function () { | ||
browserSync.init({ | ||
server: { | ||
baseDir: "test/fixtures" | ||
} | ||
}); | ||
}); | ||
@@ -79,1 +86,11 @@ /** | ||
/** | ||
* Watch stuff | ||
*/ | ||
gulp.task("watch-css", ["browser-sync-css"], function () { | ||
gulp.watch(paths.cssGlob, function (file) { | ||
browserSync.reload(file.path); | ||
}); | ||
gulp.watch(paths.html, browserSync.reload); | ||
}); | ||
@@ -185,3 +185,3 @@ "use strict"; | ||
"file:changed": function (data) { | ||
this.changeFile(data.path, options); | ||
this.changeFile(data, options); | ||
}, | ||
@@ -203,2 +203,5 @@ "file:reload": function (data) { | ||
debug(data.msg, data.vars || "", options); | ||
}, | ||
"msg:info": function (data) { | ||
utils.log("info", data.msg, options); | ||
} | ||
@@ -213,12 +216,33 @@ }; | ||
/** | ||
* @param {String} path | ||
* Instance Cleanup | ||
*/ | ||
BrowserSync.prototype.cleanup = function () { | ||
// Close any servers | ||
var server = this.servers.staticServer || this.servers.proxyServer; | ||
server.close(); | ||
// Stop any file watching | ||
if (this._watcher) { | ||
this._watcher.close(); | ||
} | ||
// Remove all event listeners | ||
this.events.removeAllListeners(); | ||
}; | ||
/** | ||
* @param {Object} data | ||
* @param {Object} options | ||
* @returns {{assetFileName: String}} | ||
*/ | ||
BrowserSync.prototype.changeFile = function (path, options) { | ||
BrowserSync.prototype.changeFile = function (data, options) { | ||
var path = data.path; | ||
var fileName = filePath.basename(path); | ||
var fileExtension = utils.getFileExtension(path); | ||
var data = { | ||
var obj = { | ||
assetFileName: fileName, | ||
@@ -232,14 +256,15 @@ fileExtension: fileExtension | ||
if (!_.contains(options.injectFileTypes, fileExtension)) { | ||
data.url = path; | ||
obj.url = path; | ||
message = "reload"; | ||
} | ||
data.cwd = this.cwd; | ||
data.path = path; | ||
data.type = message; | ||
obj.cwd = this.cwd; | ||
obj.path = path; | ||
obj.type = message; | ||
obj.log = data.log; | ||
// emit the event through socket | ||
this.events.emit("file:reload", data); | ||
this.events.emit("file:reload", obj); | ||
return data; | ||
return obj; | ||
}; | ||
@@ -273,3 +298,3 @@ | ||
debug("Static Server runnning..."); | ||
debug("Static Server running..."); | ||
} | ||
@@ -276,0 +301,0 @@ |
@@ -13,3 +13,3 @@ "use strict"; | ||
return function (files, options, emitter) { | ||
exports.init(files, options, emitter); | ||
return exports.init(files, options, emitter); | ||
}; | ||
@@ -36,2 +36,4 @@ }; | ||
watcher.on("changed", changeCallback); | ||
return watcher; | ||
}; | ||
@@ -83,3 +85,3 @@ | ||
setTimeout(function () { | ||
emitter.emit("file:changed", {path: filepath}); | ||
emitter.emit("file:changed", {path: filepath, log: true}); | ||
}, options.reloadDelay || 0); | ||
@@ -86,0 +88,0 @@ } |
@@ -21,5 +21,21 @@ "use strict"; | ||
"file:reload": function (options, data) { | ||
log("info", messages.files.changed(utils.resolveRelativeFilePath(data.path, data.cwd)), options); | ||
log("info", messages.browser[data.type](), options); | ||
if (data.log) { | ||
log("info", messages.files.changed(utils.resolveRelativeFilePath(data.path, data.cwd)), options); | ||
log("info", messages.browser[data.type](), options); | ||
} | ||
}, | ||
"stream:changed": function (options, data) { | ||
var changed = data.changed; | ||
var msg; | ||
if (!changed.length) { | ||
msg = messages.stream.once(); | ||
} else { | ||
msg = messages.stream.multi(changed); | ||
} | ||
log("info", msg, options); | ||
}, | ||
"client:connected": function (options, data) { | ||
@@ -26,0 +42,0 @@ |
@@ -10,3 +10,3 @@ "use strict"; | ||
module.exports = { | ||
var messages = { | ||
/** | ||
@@ -307,2 +307,17 @@ * @param {Object} port | ||
}, | ||
stream: { | ||
once: function () { | ||
return prefixed("{cyan:Reloading Browsers}"); | ||
}, | ||
multi: function (changed) { | ||
return prefixed("{cyan:Reloading {:count:} file{:s:} ({:files:})}", { | ||
count: changed.length, | ||
s: changed.length > 1 ? "s" : "", | ||
files: changed.join(", ") | ||
}); | ||
} | ||
}, | ||
proxyError: function () { | ||
return messages.getProxyError("Proxy address not reachable. Is your server running?"); | ||
}, | ||
getUrls: function (urls) { | ||
@@ -324,2 +339,5 @@ var output = ""; | ||
}, | ||
getProxyError: function (msg) { | ||
return prefixed("{red:PROXY ERROR: %s }".replace("%s", msg)); | ||
}, | ||
getErr: function (msg) { | ||
@@ -331,2 +349,4 @@ return "{red:%s }".replace("%s", msg); | ||
} | ||
}; | ||
}; | ||
module.exports = messages; |
"use strict"; | ||
var path = require("path"); | ||
/** | ||
@@ -8,20 +10,29 @@ * @type {{function: *}} | ||
return function (arg) { | ||
var events = browserSync.events; | ||
function emitReload(path) { | ||
browserSync.events.emit("file:changed", { | ||
path: path | ||
}); | ||
} | ||
function emitReload(path, log) { | ||
events.emit("file:changed", { | ||
path: path, | ||
log: log | ||
}); | ||
} | ||
function emitBrowserReload() { | ||
browserSync.events.emit("browser:reload"); | ||
} | ||
function emitBrowserReload() { | ||
events.emit("browser:reload"); | ||
} | ||
function emitInfo(changed) { | ||
events.emit("stream:changed", {changed: changed}); | ||
} | ||
return function (arg) { | ||
if (typeof arg === "string") { | ||
return emitReload(arg); | ||
return emitReload(arg, true); | ||
} | ||
if (Array.isArray(arg)) { | ||
return arg.forEach(emitReload); | ||
return arg.forEach(function (path) { | ||
emitReload(path, true); | ||
}); | ||
} | ||
@@ -32,7 +43,7 @@ | ||
// Handle Streams here... | ||
var emitted = false; | ||
var once = arg.once || false; | ||
var emitted = false; | ||
var once = arg.once || false; | ||
var Transform = require("stream").Transform; | ||
var reload = new Transform({objectMode:true}); | ||
var reload = new Transform({objectMode:true}); | ||
var changed = []; | ||
@@ -42,18 +53,34 @@ reload._transform = function(file, encoding, next) { | ||
if (once === true && !emitted) { | ||
emitBrowserReload(); | ||
emitted = true; | ||
this.push(file); | ||
return next(); | ||
} else { | ||
} else { // handle multiple | ||
if (once === true && emitted) { | ||
return; | ||
} else { | ||
if (file.path) { | ||
emitted = true; | ||
emitReload(file.path, false); | ||
changed.push(path.basename(file.path)); | ||
} | ||
} | ||
if (file.path) { | ||
emitted = true; | ||
emitReload(file.path); | ||
} | ||
} | ||
this.push(file); | ||
this.push(file); // always send the file down-stream | ||
next(); | ||
}; | ||
reload._flush = function (next) { | ||
emitInfo(changed); | ||
next(); | ||
}; | ||
return reload; | ||
@@ -65,2 +92,2 @@ } | ||
}; | ||
} | ||
}; |
@@ -5,2 +5,3 @@ "use strict"; | ||
var snippetUtils = require("./snippet").utils; | ||
var fail = require("./utils").utils.fail; | ||
@@ -161,3 +162,8 @@ var connect = require("connect"); | ||
snippetUtils.getRegex(scriptTags), | ||
snippetUtils.getProxyMiddleware(scripts, scriptPath) | ||
snippetUtils.getProxyMiddleware(scripts, scriptPath), | ||
function (err) { | ||
if (err.code === "ENOTFOUND") { | ||
fail(messages.proxyError(err.code), options, true); | ||
} | ||
} | ||
); | ||
@@ -164,0 +170,0 @@ } |
@@ -27,3 +27,3 @@ "use strict"; | ||
// Start file watcher | ||
this.getPlugin("file:watcher")(files, options, this.events); | ||
this._watcher = this.getPlugin("file:watcher")(files, options, this.events); | ||
@@ -30,0 +30,0 @@ // Get the Client JS |
@@ -268,3 +268,3 @@ "use strict"; | ||
fail: function (msg, options, kill) { | ||
this.log("info", msg, options); | ||
utils.log("info", msg, options); | ||
if (kill) { | ||
@@ -271,0 +271,0 @@ process.exit(1); |
{ | ||
"name": "browser-sync", | ||
"description": "Live CSS Reload & Browser Syncing", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"homepage": "https://github.com/shakyshane/browser-sync", | ||
@@ -38,3 +38,3 @@ "author": { | ||
"gaze": "~0.5.1", | ||
"http-proxy": "~1.0.2", | ||
"http-proxy": "~1.1.4", | ||
"cl-strings": "0.0.5", | ||
@@ -44,7 +44,6 @@ "resp-modifier": "0.0.4", | ||
"commander": "~2.1.0", | ||
"browser-sync-control-panel": "0.0.5", | ||
"opn": "^0.1.1", | ||
"foxy": "0.1.2", | ||
"foxy": "0.1.4", | ||
"localtunnel": "^1.3.0", | ||
"opt-merger": "^0.1.2" | ||
"opt-merger": "0.1.2" | ||
}, | ||
@@ -51,0 +50,0 @@ "devDependencies": { |
@@ -1,2 +0,2 @@ | ||
# browser-sync [![Build Status](https://travis-ci.org/shakyShane/browser-sync.png?branch=master)](https://travis-ci.org/shakyShane/browser-sync) [![NPM version](https://badge.fury.io/js/browser-sync.png)](http://badge.fury.io/js/browser-sync) [![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/) | ||
# browser-sync [![Build Status](https://travis-ci.org/shakyShane/browser-sync.png?branch=master)](https://travis-ci.org/shakyShane/browser-sync) [![NPM version](https://badge.fury.io/js/browser-sync.png)](http://badge.fury.io/js/browser-sync) | ||
@@ -16,4 +16,7 @@ > Keep multiple browsers & devices in sync when building websites. | ||
6. **Built-in Server** - Yep, I can serve static files too if you need me to (uses Connect). | ||
7. **Use with any back-end setup** - Browser-sync includes a proxy option so that it can be used with any existing PHP, Rails, Python, Node or ASP.net setup. | ||
7. **Use with any back-end setup** - I even have a proxy option so that I can be used with existing PHP, Rails, Python, Node or ASP.net setup. | ||
8. **Public URL** - View your website via a URL that any internet connected device can access & maintain all BrowserSync features. | ||
9. **Browser Stack support** - Use the all of my features when viewing your site through Browser Stack. | ||
##When is it useful? | ||
@@ -50,10 +53,11 @@ It's pretty useful when used with a single browser, watching a CSS file for changes & injecting it. But the real power comes when you're building responsive sites and using multiple devices/monitors because it can keep all browsers in sync & make your workflow much faster. | ||
``` | ||
433 Shane Osbourne | ||
520 Shane Osbourne | ||
13 Hugo Bessa | ||
3 Marek 'saji' Augustynowicz | ||
2 Hugo Dias | ||
2 chase_chou | ||
2 brutaldev | ||
2 Paul Robertson | ||
2 chase_chou | ||
2 Hugo Dias | ||
1 Tony Holdstock-Brown | ||
1 Victor Fernandez de Alba | ||
1 Werner van Deventer | ||
@@ -60,0 +64,0 @@ 1 mericson |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32527770
17
79
2727
76
+ Addedfoxy@0.1.4(transitive)
+ Addedhttp-proxy@1.1.6(transitive)
+ Addedopt-merger@0.1.2(transitive)
- Removedbrowser-sync-control-panel@0.0.5
- Removedbrowser-sync-control-panel@0.0.5(transitive)
- Removedfoxy@0.1.2(transitive)
- Removedhttp-proxy@1.0.3(transitive)
- Removedopt-merger@0.1.3(transitive)
- Removedthrough@2.3.4(transitive)
Updatedfoxy@0.1.4
Updatedhttp-proxy@~1.1.4
Updatedopt-merger@0.1.2