browser-sync
Advanced tools
Comparing version 1.2.0 to 1.2.1
var browserSync = require("./index"); | ||
var connect = require("connect"); | ||
@@ -10,3 +11,6 @@ console.time("init"); | ||
server: { | ||
baseDir: ["test/fixtures"] | ||
baseDir: "./test/fixtures" | ||
// routes: { | ||
// "/shane": "test/fixtures" | ||
// } | ||
}, | ||
@@ -31,10 +35,11 @@ // proxy: "swoon.static/store-home.php", | ||
var cp = require("/Users/shakyshane/Sites/browser-sync-modules/browser-sync-cp/index"); | ||
//var cp = require("/Users/shakyshane/Sites/browser-sync-modules/browser-sync-cp/index"); | ||
// | ||
////console.log(cp); | ||
// | ||
//browserSync.use(cp); | ||
//console.log(cp); | ||
browserSync(options, function (err, bs) { | ||
bs.app.use("/shan", bs.connect.static("test/fixtures")); | ||
}); | ||
browserSync.use(cp); | ||
var bs = browserSync(options, function (err, bs) { | ||
// setTimeout(browserSync.exit, 3000); | ||
}); |
@@ -352,3 +352,3 @@ "use strict"; | ||
var bsServer = serverModule.launchServer(options, scripts, middleware); | ||
var bsServer = serverModule.launchServer(options, scripts, middleware, this); | ||
@@ -396,2 +396,3 @@ if (server || snippet) { | ||
module.exports = BrowserSync; | ||
module.exports = BrowserSync; | ||
@@ -15,6 +15,8 @@ "use strict"; | ||
* @param {Object} options | ||
* @param {string|} scripts | ||
* @param {String|} scripts | ||
* @param {Array} mw | ||
* @param {BrowserSync} context | ||
* @returns {{staticServer: (http.Server), proxyServer: (http.Server)}|Boolean} | ||
*/ | ||
module.exports.launchServer = function (options, scripts, mw) { | ||
module.exports.launchServer = function (options, scripts, mw, context) { | ||
@@ -55,3 +57,3 @@ var proxy = options.proxy || false; | ||
var baseDir, index, directory; | ||
var baseDir, index, directory, routes; | ||
@@ -62,5 +64,7 @@ if (server) { | ||
directory = server.directory; | ||
routes = server.routes; | ||
} | ||
app = connect(); | ||
app = context.app = connect(); | ||
context.connect = connect; | ||
@@ -88,5 +92,10 @@ if (server) { | ||
app.use(snippetUtils.getSnippetMiddleware(scriptTags)); | ||
utils.addBaseDir(app, baseDir, index); | ||
if (routes) { | ||
utils.addRoutes(app, routes); | ||
} | ||
} | ||
@@ -93,0 +102,0 @@ |
@@ -5,2 +5,3 @@ "use strict"; | ||
var connect = require("connect"); | ||
var _ = require("lodash"); | ||
var snippetUtils = require("./../snippet").utils; | ||
@@ -121,3 +122,14 @@ | ||
app.use(connect.directory(filePath.resolve(base), {icons:true})); | ||
}, | ||
/** | ||
* @param app | ||
* @param {Object} routes | ||
*/ | ||
addRoutes: function (app, routes) { | ||
Object.keys(routes).forEach(function (key) { | ||
if (_.isString(key) && _.isString(routes[key])) { | ||
app.use(key, connect.static(filePath.resolve(routes[key]))); | ||
} | ||
}); | ||
} | ||
}; |
{ | ||
"name": "browser-sync", | ||
"description": "Live CSS Reload & Browser Syncing", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"homepage": "https://github.com/shakyshane/browser-sync", | ||
@@ -6,0 +6,0 @@ "author": { |
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
3592621
3007