browser-sync
Advanced tools
Comparing version 0.5.2 to 0.5.3
"use strict"; | ||
var compileWithPrefix = require("cl-strings").getCompiler("{green:[}BS{green:]}"); | ||
var compile = require("cl-strings").compile; | ||
var path = require("path"); | ||
@@ -13,3 +15,3 @@ module.exports = { | ||
var template = "\n\n{cyan:All Set Up!} Now copy & paste this snippet just before the closing </body> tag in your website.\n\n {: tags :}"; | ||
var template = "{green:Copy the following snippet into your website, just before the closing} </body> {green:tag}\n\n{:tags:}"; | ||
var params = { | ||
@@ -19,3 +21,3 @@ tags: this.scriptTags(hostIp, ports) | ||
return compile(template, params); | ||
return compileWithPrefix(template, params); | ||
}, | ||
@@ -25,3 +27,3 @@ server: { | ||
var template = "{red:Invalid config. You cannot specify both a server & proxy option.}"; | ||
return compile(template); | ||
return compileWithPrefix(template); | ||
} | ||
@@ -37,11 +39,13 @@ }, | ||
var template = "\n{green:OK, Server running at} {magenta:{: url :}}"; | ||
template += "\n{green:Serving files from:} {magenta:{: baseDir :}}"; | ||
template += "\n\n{green:Load a browser & check back here. If you set up everything correctly, you'll see a} {cyan:'Browser Connected'} {green:message}\n"; | ||
var params = { | ||
url: this._makeUrl(host, port, "http:"), | ||
baseDir: baseDir | ||
}; | ||
var output = ""; | ||
return compile(template, params); | ||
var template = "{green:Server running. Use this URL:} {magenta:{: url :}}\n"; | ||
output += compileWithPrefix(template, { | ||
url: this._makeUrl(host, port, "http:") | ||
}); | ||
template = "{green:Serving files from:} {magenta:{: baseDir :}}"; | ||
output += compileWithPrefix(template, {baseDir: baseDir}); | ||
return output; | ||
}, | ||
@@ -61,3 +65,3 @@ /** | ||
return compile(template, params); | ||
return compileWithPrefix(template, params); | ||
}, | ||
@@ -90,3 +94,3 @@ /** | ||
template += "<script>{: connector :}</script>\n"; | ||
template += "<script src='{: custom :}'></script>\n\n"; | ||
template += "<script src='{: custom :}'></script>\n"; | ||
@@ -115,3 +119,3 @@ var socket = this._makeUrl(hostIp, ports.socket) + this.socketIoScript; | ||
return compile(template, {}); | ||
return compileWithPrefix(template); | ||
}, | ||
@@ -129,3 +133,3 @@ ports: { | ||
return compile(template, params); | ||
return compileWithPrefix(template, params); | ||
} | ||
@@ -138,10 +142,11 @@ }, | ||
*/ | ||
confirm: function (path) { | ||
var template = "Config file created at {cyan:{:path:}}\n"; | ||
template += "To use it, in the same directory run: {green:browser-sync}"; | ||
confirm: function (filePath) { | ||
var template1 = "Config file created ({cyan:{:path:}})"; | ||
var template2 = "To use it, in the same directory run: {green:browser-sync}"; | ||
var params = { | ||
path: path | ||
"path": path.basename(filePath) | ||
}; | ||
return compile(template, params); | ||
return compileWithPrefix([template1, template2], params); | ||
} | ||
@@ -155,24 +160,10 @@ }, | ||
*/ | ||
watching: function (patterns, patternLimit) { | ||
watching: function (patterns) { | ||
var string, limit = patternLimit || 10; | ||
var string; | ||
if (Array.isArray(patterns) && patterns.length) { | ||
string = compile("{green:Watching the following:}\n"); | ||
var slice = patterns.slice(0, limit); | ||
slice.forEach(function (item) { | ||
string += item.replace(" ", "") + "\n"; | ||
}); | ||
if (patterns.length > limit) { | ||
string += "Plus more...\n"; | ||
} | ||
string = compileWithPrefix("{green:Watching files...}"); | ||
} else { | ||
string = compile("{red:Not watching any files...}"); | ||
string = compileWithPrefix("{red:Not watching any files...}"); | ||
} | ||
return string; | ||
@@ -184,5 +175,7 @@ }, | ||
*/ | ||
changed: function (path) { | ||
var string = "{magenta:File Changed: }{green:{: path :}}"; | ||
return compile(string, {path: path}); | ||
changed: function (fileName) { | ||
var string = "{green:File Changed: }{magenta:{: path :}}"; | ||
return compileWithPrefix(string, { | ||
path: path.basename(fileName) | ||
}); | ||
} | ||
@@ -196,3 +189,3 @@ }, | ||
var string = "{cyan:Reloading all connected browsers...}"; | ||
return compile(string); | ||
return compileWithPrefix(string); | ||
}, | ||
@@ -204,3 +197,3 @@ /** | ||
var string = "{cyan:Injecting file into all connected browsers...}"; | ||
return compile(string); | ||
return compileWithPrefix(string); | ||
}, | ||
@@ -219,3 +212,3 @@ /** | ||
return compile(template, params); | ||
return compileWithPrefix(template, params); | ||
} | ||
@@ -228,7 +221,7 @@ }, | ||
location: function (url) { | ||
var template = "{yellow:Link clicked! Redirecting all browsers to }{green:{: url :}}"; | ||
var template = "{green:Link clicked! Redirecting all browsers to }{magenta:{: url :}}"; | ||
var params = { | ||
url: url | ||
}; | ||
return compile(template, params); | ||
return compileWithPrefix(template, params); | ||
}, | ||
@@ -235,0 +228,0 @@ /** |
@@ -28,2 +28,5 @@ "use strict"; | ||
], | ||
bodyPattern: /<body[^>]*>/i, | ||
/** | ||
@@ -38,3 +41,3 @@ * Check if HTML body exists | ||
} | ||
return (~body.lastIndexOf("</body>")); | ||
return (body.match(this.bodyPattern)); | ||
}, | ||
@@ -79,4 +82,4 @@ /** | ||
if (utils.bodyExists(body)) { | ||
body = body.replace(/<\/body>/, function (w) { | ||
return tags + w; | ||
body = body.replace(utils.bodyPattern, function (w) { | ||
return w + tags; | ||
}); | ||
@@ -107,2 +110,2 @@ } | ||
}; | ||
}; | ||
}; |
{ | ||
"name": "browser-sync", | ||
"description": "Live CSS Reload & Browser Syncing", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"homepage": "https://github.com/shakyshane/browser-sync", | ||
@@ -42,3 +42,3 @@ "author": { | ||
"http-proxy": "~0.10.3", | ||
"cl-strings": "~0.0.2" | ||
"cl-strings": "~0.0.3" | ||
}, | ||
@@ -68,3 +68,4 @@ "devDependencies": { | ||
"karma-mocha": "~0.1.1", | ||
"karma-sinon": "~1.0.0" | ||
"karma-sinon": "~1.0.0", | ||
"cl-strings": "0.0.4" | ||
}, | ||
@@ -71,0 +72,0 @@ "keywords": [ |
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
269178
24
2730
Updatedcl-strings@~0.0.3