This commit is contained in:
tatianamac
2019-11-26 14:50:43 -08:00
parent 8a55660ed0
commit 6d5445ecc5
13894 changed files with 2233957 additions and 0 deletions

1
node_modules/bs-snippet-injector/.npmignore generated vendored Normal file
View File

@@ -0,0 +1 @@
.idea

5
node_modules/bs-snippet-injector/example.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
var bs = require("browser-sync");
bs.use(require("./index"), {file: "index.html"});
bs();

10
node_modules/bs-snippet-injector/index.html generated vendored Normal file
View File

@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
</body>
</html>

119
node_modules/bs-snippet-injector/index.js generated vendored Normal file
View File

@@ -0,0 +1,119 @@
var fs = require("fs");
var path = require("path");
/**
* @type {string}
*/
var PLUGIN_NAME = "Snippet Injector";
/**
* @type
*/
var messages = {
added: function (path) {
return "{green:Snippet added to {cyan:" + path
},
removed: function (path) {
return "{green:Snippet removed from {cyan:" + path
},
exists: function (path) {
return "{green:Snippet already exists in: {cyan:" + path
},
notFound: function (path) {
return "{red:ERROR:} Closing body tag not found in: {cyan:" + path
},
fileNotFound: function (path) {
return "{red:ERROR:} File not found!: {cyan:" + path
}
};
/**
* Main export
* @type {{name: string, plugin: plugin}}
*/
module.exports = {
"plugin:name": PLUGIN_NAME,
plugin: function (opts, bs) {
opts.file = opts.file || "";
opts.currentFilePath = path.resolve(opts.file);
opts.logger = bs.getLogger(PLUGIN_NAME);
opts.logger.debug("Setting events");
bs.events.on("service:running", addSnippet.bind(null, bs, opts));
bs.events.on("service:exit", removeSnippet.bind(null, bs, opts));
}
};
/**
* Add the snippet before a body tag
* @param {BrowserSync} bs
* @param {Object} opts - plugin specific options
*/
function addSnippet(bs, opts) {
var currentFilePath = opts.currentFilePath;
opts.logger.debug("Reading the file: %s", currentFilePath);
var read;
try {
read = fs.readFileSync(currentFilePath, "utf8");
} catch (e) {
opts.errored = true;
return opts.logger.info(messages.fileNotFound(path.basename(currentFilePath)));
}
var found = false;
if (read.indexOf(bs.options.get("snippet")) > -1) {
opts.logger.info(messages.exists(currentFilePath));
return;
}
var modded = read.replace(/<\/body>(?![\s\S]*<\/body>)/, function () {
opts.currentSnippet = wrap(bs.options.get("snippet")) + "\n" + arguments[0];
found = true;
return opts.currentSnippet;
});
if (found) {
opts.logger.debug("Writing the file: %s", currentFilePath);
fs.writeFileSync(currentFilePath, modded);
opts.logger.info(messages.added(path.basename(currentFilePath)));
} else {
opts.logger.info(messages.notFound(path.basename(currentFilePath)));
}
}
/**
* @param item snippet
* @returns {string}
*/
function wrap (item) {
return "<!-- BS:SNIPPET-->" + item + "<!-- BS:SNIPPET:END-->";
}
/**
* @param {BrowserSync} bs
* @param {Object} opts - plugin specific options
*/
function removeSnippet(bs, opts) {
if (opts.errored) {
return;
}
var read = fs.readFileSync(opts.currentFilePath, "utf8");
var modded = read.replace(opts.currentSnippet, function () {
return "</body>";
});
fs.writeFileSync(opts.currentFilePath, modded);
opts.logger.info(messages.removed(path.basename(opts.currentFilePath)));
}

56
node_modules/bs-snippet-injector/package.json generated vendored Normal file
View File

@@ -0,0 +1,56 @@
{
"_args": [
[
"bs-snippet-injector@2.0.1",
"/Users/tatiana/selfdefined"
]
],
"_from": "bs-snippet-injector@2.0.1",
"_id": "bs-snippet-injector@2.0.1",
"_inBundle": false,
"_integrity": "sha1-YbU5PxH1JVntEgaTEANDtu2wTdU=",
"_location": "/bs-snippet-injector",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "bs-snippet-injector@2.0.1",
"name": "bs-snippet-injector",
"escapedName": "bs-snippet-injector",
"rawSpec": "2.0.1",
"saveSpec": null,
"fetchSpec": "2.0.1"
},
"_requiredBy": [
"/browser-sync"
],
"_resolved": "https://registry.npmjs.org/bs-snippet-injector/-/bs-snippet-injector-2.0.1.tgz",
"_spec": "2.0.1",
"_where": "/Users/tatiana/selfdefined",
"author": {
"name": "Shane Osbourne"
},
"bugs": {
"url": "https://github.com/shakyShane/bs-snippet-injector/issues"
},
"description": "Write & Remove the BrowserSync Snippet to a file",
"devDependencies": {
"browser-sync": "2.4.0"
},
"homepage": "https://github.com/shakyShane/bs-snippet-injector",
"keywords": [
"browser",
"sync"
],
"license": "MIT",
"main": "index.js",
"name": "bs-snippet-injector",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/shakyShane/bs-snippet-injector.git"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "2.0.1"
}

28
node_modules/bs-snippet-injector/readme.md generated vendored Normal file
View File

@@ -0,0 +1,28 @@
###bs-snippet-injector
Write & Remove the BrowserSync Snippet to a file
This is an alternative to using the BrowserSync proxy.
##Install
```bash
$ npm install browser-sync bs-snippet-injector
```
###Example
```js
// requires version 1.3.3 of BrowserSync or higher.
var browserSync = require("browser-sync");
// register the plugin
browserSync.use(require("bs-snippet-injector"), {
// path to the file containing the closing </body> tag
file: "app/design/frontend/project/template/page/1column.phtml"
});
// now run BrowserSync, wathching CSS files.
browserSync({
files: "skin/frontend/project/assets/css/*.css"
});
```