Skip to content

Commit

Permalink
tweak width
Browse files Browse the repository at this point in the history
  • Loading branch information
Shane Osbourne committed Apr 26, 2023
1 parent 2ab7ec3 commit f287659
Show file tree
Hide file tree
Showing 33 changed files with 393 additions and 121 deletions.
24 changes: 19 additions & 5 deletions packages/browser-sync/lib/async.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ module.exports = {
require("dns").resolve("www.google.com", function(err) {
var online = false;
if (err) {
bs.debug("Could not resolve www.google.com, setting %s", chalk.magenta("online: false"));
bs.debug(
"Could not resolve www.google.com, setting %s",
chalk.magenta("online: false")
);
} else {
bs.debug("Resolved www.google.com, setting %s", chalk.magenta("online: true"));
online = true;
Expand Down Expand Up @@ -141,9 +144,15 @@ module.exports = {
done(null, {
options: {
urls: utils.getUrlOptions(bs.options),
snippet: connectUtils.enabled(bs.options) ? connectUtils.scriptTags(bs.options) : false,
snippet: connectUtils.enabled(bs.options)
? connectUtils.scriptTags(bs.options)
: false,
scriptPaths: Immutable.fromJS(connectUtils.clientScript(bs.options, true)),
files: bs.pluginManager.hook("files:watch", bs.options.get("files"), bs.pluginManager.pluginOptions)
files: bs.pluginManager.hook(
"files:watch",
bs.options.get("files"),
bs.pluginManager.pluginOptions
)
}
});
},
Expand Down Expand Up @@ -224,7 +233,10 @@ module.exports = {
* @param {Function} done
*/
startSockets: function(bs, done) {
var clientEvents = bs.pluginManager.hook("client:events", bs.options.get("clientEvents").toJS());
var clientEvents = bs.pluginManager.hook(
"client:events",
bs.options.get("clientEvents").toJS()
);

// Start the socket, needs an existing server.
var io = bs.pluginManager.get("socket")(bs.server, clientEvents, bs);
Expand Down Expand Up @@ -259,7 +271,9 @@ module.exports = {
return item.name === PLUGIN_NAME;
})
) {
uiOpts = bs.options.get("ui").mergeDeep(Immutable.fromJS(bs.pluginManager.pluginOptions[PLUGIN_NAME]));
uiOpts = bs.options
.get("ui")
.mergeDeep(Immutable.fromJS(bs.pluginManager.pluginOptions[PLUGIN_NAME]));
}

/**
Expand Down
4 changes: 3 additions & 1 deletion packages/browser-sync/lib/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ function handleNoCommand(argv, input, yargs) {
return process.exit(1);
}

const serveStaticPaths = withoutErrors.filter(item => item.isUrl === false).map(item => item.resolved);
const serveStaticPaths = withoutErrors
.filter(item => item.isUrl === false)
.map(item => item.resolved);

const urls = withoutErrors.filter(item => item.isUrl === true).map(item => item.userInput);

Expand Down
3 changes: 2 additions & 1 deletion packages/browser-sync/lib/cli/cli-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ var info = {
fs.writeFile(path.resolve(cwd, config.userFile), file, function() {
logger.info("Config file created %s", chalk.magenta(config.userFile));
logger.info(
"To use it, in the same directory run: " + chalk.cyan("browser-sync start --config bs-config.js")
"To use it, in the same directory run: " +
chalk.cyan("browser-sync start --config bs-config.js")
);
cb();
});
Expand Down
5 changes: 4 additions & 1 deletion packages/browser-sync/lib/cli/cli-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ export function printErrors(errors: BsErrors) {
`Error Type: ${error.type}`,
`Error Level: ${error.level}`,
error.errors.map(item =>
[`Error Message: ${item.error.message}`, item.meta ? item.meta().join("\n") : ""]
[
`Error Message: ${item.error.message}`,
item.meta ? item.meta().join("\n") : ""
]
.filter(Boolean)
.join("\n")
)
Expand Down
5 changes: 4 additions & 1 deletion packages/browser-sync/lib/cli/command.recipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ module.exports = function(opts) {

var logRecipes = function() {
var dirs = fs.readdirSync(path.join(dir, "recipes"));
logger.info("Install one of the following with %s\n", chalk.cyan("browser-sync recipe <name>"));
logger.info(
"Install one of the following with %s\n",
chalk.cyan("browser-sync recipe <name>")
);
dirs.forEach(function(name) {
console.log(" " + name);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { List } from "immutable";
import { BsTempOptions, TransformResult } from "../cli-options";

const defaultIgnorePatterns = [/node_modules/, /bower_components/, ".sass-cache", ".vscode", ".git", ".idea"];
const defaultIgnorePatterns = [
/node_modules/,
/bower_components/,
".sass-cache",
".vscode",
".git",
".idea"
];

export function addDefaultIgnorePatterns(incoming: BsTempOptions): TransformResult {
if (!incoming.get("watch")) {
Expand Down
3 changes: 2 additions & 1 deletion packages/browser-sync/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = {
},
errors: {
"server+proxy": "Invalid config. You cannot specify both server & proxy options.",
"proxy+https": "Invalid config. You set https: true, but your proxy target doesn't reflect this."
"proxy+https":
"Invalid config. You set https: true, but your proxy target doesn't reflect this."
}
};
7 changes: 6 additions & 1 deletion packages/browser-sync/lib/connect-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ var connectUtils = {
*/
var scriptSrc = (function() {
if (options.get("localOnly")) {
return [options.get("scheme"), "://localhost:", options.get("port"), scriptPath].join("");
return [
options.get("scheme"),
"://localhost:",
options.get("port"),
scriptPath
].join("");
}

/**
Expand Down
10 changes: 9 additions & 1 deletion packages/browser-sync/lib/default-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,15 @@ module.exports = {
*/
timestamps: true,

clientEvents: ["scroll", "scroll:element", "input:text", "input:toggles", "form:submit", "form:reset", "click"],
clientEvents: [
"scroll",
"scroll:element",
"input:text",
"input:toggles",
"form:submit",
"form:reset",
"click"
],

/**
* Alter the script path for complete control over where the Browsersync
Expand Down
6 changes: 5 additions & 1 deletion packages/browser-sync/lib/file-watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ module.exports.plugin = function(bs) {
if (!_.isFunction(item.fn)) {
item.fn = fn;
}
var watcher = watch(item.match, item.options || defaultWatchOptions, item.fn.bind(bs.publicInstance));
var watcher = watch(
item.match,
item.options || defaultWatchOptions,
item.fn.bind(bs.publicInstance)
);
if (!map[namespace]) {
map[namespace] = {
watchers: [watcher]
Expand Down
12 changes: 10 additions & 2 deletions packages/browser-sync/lib/http-protocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ var queryString = require("qs");
var proto = exports;
var instanceMethods = ["exit", "notify", "pause", "resume"];
var getBody = require("raw-body");
const permittedSocketEvents = ["file:reload", "browser:reload", "browser:notify", "browser:location", "options:set"];
const permittedSocketEvents = [
"file:reload",
"browser:reload",
"browser:notify",
"browser:location",
"options:set"
];

/**
* Does the requested method expect an instance of BrowserSync
Expand Down Expand Up @@ -49,7 +55,9 @@ proto.middleware = function(bs) {
try {
const [name, payload] = JSON.parse(body.toString());
bs.io.sockets.emit(name, payload);
return res.end(`Browsersync HTTP Protocol received: ${name} ${JSON.stringify(payload)}`);
return res.end(
`Browsersync HTTP Protocol received: ${name} ${JSON.stringify(payload)}`
);
} catch (e) {
const output = [`Error: ${e.message}`];
res.writeHead(500, { "Content-Type": "text/plain" });
Expand Down
26 changes: 14 additions & 12 deletions packages/browser-sync/lib/internal-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,20 @@ module.exports = function(bs) {
return x.namespace === "core";
});

var handler = fileHandler.fileChanges(coreNamespacedWatchers, bs.options).subscribe(function(x) {
if (x.type === "reload") {
bs.events.emit("browser:reload", x);
}
if (x.type === "inject") {
x.files.forEach(function(data) {
if (!bs.paused && data.namespace === "core") {
bs.events.emit("file:reload", fileUtils.getFileInfo(data, bs.options));
}
});
}
});
var handler = fileHandler
.fileChanges(coreNamespacedWatchers, bs.options)
.subscribe(function(x) {
if (x.type === "reload") {
bs.events.emit("browser:reload", x);
}
if (x.type === "inject") {
x.files.forEach(function(data) {
if (!bs.paused && data.namespace === "core") {
bs.events.emit("file:reload", fileUtils.getFileInfo(data, bs.options));
}
});
}
});

bs.registerCleanupTask(function() {
handler.dispose();
Expand Down
Loading

0 comments on commit f287659

Please sign in to comment.