diff options
| author | 2021-02-03 19:17:50 -0500 | |
|---|---|---|
| committer | 2021-02-03 19:17:50 -0500 | |
| commit | 475d074fd74425efbe783fad08f97f2df0c4909f (patch) | |
| tree | 2acdae53999b3c74b716efa4edb5b40311fa356a /npm_assets/node_modules/livereload-js/lib/less.js | |
| parent | cd502d52787f666fff3254d7d7e7578930c813c2 (diff) | |
| parent | 3a0d66f07b112b6d2bdc2b57bbf717a89a351ce6 (diff) | |
Update upstream source from tag 'upstream/8.1.2'
Update to upstream version '8.1.2'
with Debian dir e5e966a9e6010ef70618dc9a61558fa4db35aceb
Diffstat (limited to 'npm_assets/node_modules/livereload-js/lib/less.js')
| -rw-r--r-- | npm_assets/node_modules/livereload-js/lib/less.js | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/npm_assets/node_modules/livereload-js/lib/less.js b/npm_assets/node_modules/livereload-js/lib/less.js new file mode 100644 index 0000000..619c6b8 --- /dev/null +++ b/npm_assets/node_modules/livereload-js/lib/less.js @@ -0,0 +1,62 @@ +(function() { + var LessPlugin; + + module.exports = LessPlugin = (function() { + LessPlugin.identifier = 'less'; + + LessPlugin.version = '1.0'; + + function LessPlugin(window, host) { + this.window = window; + this.host = host; + } + + LessPlugin.prototype.reload = function(path, options) { + if (this.window.less && this.window.less.refresh) { + if (path.match(/\.less$/i)) { + return this.reloadLess(path); + } + if (options.originalPath.match(/\.less$/i)) { + return this.reloadLess(options.originalPath); + } + } + return false; + }; + + LessPlugin.prototype.reloadLess = function(path) { + var i, len, link, links; + links = (function() { + var i, len, ref, results; + ref = document.getElementsByTagName('link'); + results = []; + for (i = 0, len = ref.length; i < len; i++) { + link = ref[i]; + if (link.href && link.rel.match(/^stylesheet\/less$/i) || (link.rel.match(/stylesheet/i) && link.type.match(/^text\/(x-)?less$/i))) { + results.push(link); + } + } + return results; + })(); + if (links.length === 0) { + return false; + } + for (i = 0, len = links.length; i < len; i++) { + link = links[i]; + link.href = this.host.generateCacheBustUrl(link.href); + } + this.host.console.log("LiveReload is asking LESS to recompile all stylesheets"); + this.window.less.refresh(true); + return true; + }; + + LessPlugin.prototype.analyze = function() { + return { + disable: !!(this.window.less && this.window.less.refresh) + }; + }; + + return LessPlugin; + + })(); + +}).call(this); |
