Skip to content

Commit 3ca678e

Browse files
author
Shane Osbourne
committed
prettier config
1 parent f91440e commit 3ca678e

File tree

83 files changed

+474
-1576
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+474
-1576
lines changed

packages/browser-sync/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/dist/*
2+
/dist_backup/*

packages/browser-sync/lib/async.js

Lines changed: 22 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var Immutable = require("immutable");
66
var utils = require("./utils");
77
var pluginUtils = require("./plugins");
88
var connectUtils = require("./connect-utils");
9-
var chalk = require("chalk");
9+
var chalk = require("chalk");
1010

1111
module.exports = {
1212
/**
@@ -63,24 +63,19 @@ module.exports = {
6363
socketPort = bs.options.getIn(["socket", "port"]);
6464
}
6565

66-
utils.getPort(
67-
bs.options.get("listen", "localhost"),
68-
socketPort,
69-
null,
70-
function(err, port) {
71-
if (err) {
72-
return utils.fail(true, err, bs.cb);
73-
}
74-
done(null, {
75-
optionsIn: [
76-
{
77-
path: ["socket", "port"],
78-
value: port
79-
}
80-
]
81-
});
66+
utils.getPort(bs.options.get("listen", "localhost"), socketPort, null, function(err, port) {
67+
if (err) {
68+
return utils.fail(true, err, bs.cb);
8269
}
83-
);
70+
done(null, {
71+
optionsIn: [
72+
{
73+
path: ["socket", "port"],
74+
value: port
75+
}
76+
]
77+
});
78+
});
8479
},
8580
/**
8681
* Some features require an internet connection.
@@ -91,22 +86,13 @@ module.exports = {
9186
* @param {Function} done
9287
*/
9388
getOnlineStatus: function(bs, done) {
94-
if (
95-
_.isUndefined(bs.options.get("online")) &&
96-
_.isUndefined(process.env.TESTING)
97-
) {
89+
if (_.isUndefined(bs.options.get("online")) && _.isUndefined(process.env.TESTING)) {
9890
require("dns").resolve("www.google.com", function(err) {
9991
var online = false;
10092
if (err) {
101-
bs.debug(
102-
"Could not resolve www.google.com, setting %s",
103-
chalk.magenta("online: false")
104-
);
93+
bs.debug("Could not resolve www.google.com, setting %s", chalk.magenta("online: false"));
10594
} else {
106-
bs.debug(
107-
"Resolved www.google.com, setting %s",
108-
chalk.magenta("online: true")
109-
);
95+
bs.debug("Resolved www.google.com, setting %s", chalk.magenta("online: true"));
11096
online = true;
11197
}
11298
done(null, {
@@ -155,17 +141,9 @@ module.exports = {
155141
done(null, {
156142
options: {
157143
urls: utils.getUrlOptions(bs.options),
158-
snippet: connectUtils.enabled(bs.options)
159-
? connectUtils.scriptTags(bs.options)
160-
: false,
161-
scriptPaths: Immutable.fromJS(
162-
connectUtils.clientScript(bs.options, true)
163-
),
164-
files: bs.pluginManager.hook(
165-
"files:watch",
166-
bs.options.get("files"),
167-
bs.pluginManager.pluginOptions
168-
)
144+
snippet: connectUtils.enabled(bs.options) ? connectUtils.scriptTags(bs.options) : false,
145+
scriptPaths: Immutable.fromJS(connectUtils.clientScript(bs.options, true)),
146+
files: bs.pluginManager.hook("files:watch", bs.options.get("files"), bs.pluginManager.pluginOptions)
169147
}
170148
});
171149
},
@@ -195,10 +173,7 @@ module.exports = {
195173
mergeMiddlewares: function(bs, done) {
196174
done(null, {
197175
options: {
198-
middleware: bs.pluginManager.hook(
199-
"server:middleware",
200-
bs.options.get("middleware")
201-
)
176+
middleware: bs.pluginManager.hook("server:middleware", bs.options.get("middleware"))
202177
}
203178
});
204179
},
@@ -249,10 +224,7 @@ module.exports = {
249224
* @param {Function} done
250225
*/
251226
startSockets: function(bs, done) {
252-
var clientEvents = bs.pluginManager.hook(
253-
"client:events",
254-
bs.options.get("clientEvents").toJS()
255-
);
227+
var clientEvents = bs.pluginManager.hook("client:events", bs.options.get("clientEvents").toJS());
256228

257229
// Start the socket, needs an existing server.
258230
var io = bs.pluginManager.get("socket")(bs.server, clientEvents, bs);
@@ -287,13 +259,7 @@ module.exports = {
287259
return item.name === PLUGIN_NAME;
288260
})
289261
) {
290-
uiOpts = bs.options
291-
.get("ui")
292-
.mergeDeep(
293-
Immutable.fromJS(
294-
bs.pluginManager.pluginOptions[PLUGIN_NAME]
295-
)
296-
);
262+
uiOpts = bs.options.get("ui").mergeDeep(Immutable.fromJS(bs.pluginManager.pluginOptions[PLUGIN_NAME]));
297263
}
298264

299265
/**

packages/browser-sync/lib/bin.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
const startOpts = require("../cli-options/opts.start.json");
33
const reloadOpts = require("../cli-options/opts.reload.json");
44
const recipeOpts = require("../cli-options/opts.recipe.json");
5-
const chalk = require("chalk");
5+
const chalk = require("chalk");
66
const pkg = require("../package.json");
77
import * as utils from "./utils";
88
import { resolve } from "path";
@@ -38,7 +38,7 @@ if (!module.parent) {
3838
}
3939

4040
function freshYargs() {
41-
return require("yargs")(process.argv.slice(2));
41+
return require("yargs")(process.argv.slice(2));
4242
}
4343

4444
function runFromCli() {
@@ -128,13 +128,9 @@ function handleNoCommand(argv, input, yargs) {
128128
return process.exit(1);
129129
}
130130

131-
const serveStaticPaths = withoutErrors
132-
.filter(item => item.isUrl === false)
133-
.map(item => item.resolved);
131+
const serveStaticPaths = withoutErrors.filter(item => item.isUrl === false).map(item => item.resolved);
134132

135-
const urls = withoutErrors
136-
.filter(item => item.isUrl === true)
137-
.map(item => item.userInput);
133+
const urls = withoutErrors.filter(item => item.isUrl === true).map(item => item.userInput);
138134

139135
/**
140136
* If a URL was given, switch to proxy mode and use
@@ -183,8 +179,7 @@ function processStart(yargs) {
183179
.options(startOpts)
184180
.example("$0 start -s app", "- Use the App directory to serve files")
185181
.example("$0 start -p www.bbc.co.uk", "- Proxy an existing website")
186-
.default("cwd", () => process.cwd())
187-
.argv;
182+
.default("cwd", () => process.cwd()).argv;
188183
}
189184

190185
/**
@@ -210,17 +205,15 @@ function handleIncoming(command, yargs) {
210205
.options(reloadOpts)
211206
.example("$0 reload")
212207
.example("$0 reload --port 4000")
213-
.default("cwd", () => process.cwd())
214-
.argv;
208+
.default("cwd", () => process.cwd()).argv;
215209
}
216210
if (command === "recipe") {
217211
out = yargs
218212
.usage("Usage: $0 recipe <recipe-name>")
219213
.option(recipeOpts)
220214
.example("$0 recipe ls", "list the recipes")
221215
.example("$0 recipe gulp.sass", "use the gulp.sass recipe")
222-
.default("cwd", () => process.cwd())
223-
.argv;
216+
.default("cwd", () => process.cwd()).argv;
224217
}
225218

226219
if (out.help) {

packages/browser-sync/lib/browser-sync.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var config = require("./config");
66
var connectUtils = require("./connect-utils");
77
var utils = require("./utils");
88
var logger = require("./logger");
9-
var chalk = require("chalk");
9+
var chalk = require("chalk");
1010

1111
var eachSeries = utils.eachSeries;
1212
var _ = require("./lodash.custom");
@@ -535,11 +535,7 @@ BrowserSync.prototype.setOptionIn = function(path, value, opts) {
535535

536536
opts = opts || {};
537537

538-
bs.debug(
539-
"Setting Option: {cyan:%s} - {magenta:%s",
540-
path.join("."),
541-
value.toString()
542-
);
538+
bs.debug("Setting Option: {cyan:%s} - {magenta:%s", path.join("."), value.toString());
543539
bs.options = bs.options.setIn(path, value);
544540
if (!opts.silent) {
545541
bs.events.emit("options:set", {

packages/browser-sync/lib/cli/cli-info.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ var info = {
4848
fs.writeFile(path.resolve(cwd, config.userFile), file, function() {
4949
logger.info("Config file created %s", chalk.magenta(config.userFile));
5050
logger.info(
51-
"To use it, in the same directory run: " +
52-
chalk.cyan("browser-sync start --config bs-config.js")
51+
"To use it, in the same directory run: " + chalk.cyan("browser-sync start --config bs-config.js")
5352
);
5453
cb();
5554
});

packages/browser-sync/lib/cli/cli-options.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,7 @@ export function printErrors(errors: BsErrors) {
128128
`Error Type: ${error.type}`,
129129
`Error Level: ${error.level}`,
130130
error.errors.map(item =>
131-
[
132-
`Error Message: ${item.error.message}`,
133-
item.meta ? item.meta().join("\n") : ""
134-
]
131+
[`Error Message: ${item.error.message}`, item.meta ? item.meta().join("\n") : ""]
135132
.filter(Boolean)
136133
.join("\n")
137134
)

packages/browser-sync/lib/cli/command.recipe.js

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22
var logger = require("../logger").logger;
3-
var chalk = require("chalk");
3+
var chalk = require("chalk");
44

55
/**
66
* $ browser-sync recipe <name> <options>
@@ -20,10 +20,7 @@ module.exports = function(opts) {
2020

2121
var logRecipes = function() {
2222
var dirs = fs.readdirSync(path.join(dir, "recipes"));
23-
logger.info(
24-
"Install one of the following with %s\n",
25-
chalk.cyan('browser-sync recipe <name>')
26-
);
23+
logger.info("Install one of the following with %s\n", chalk.cyan("browser-sync recipe <name>"));
2724
dirs.forEach(function(name) {
2825
console.log(" " + name);
2926
});
@@ -42,15 +39,11 @@ module.exports = function(opts) {
4239

4340
input = input[0];
4441
var flags = opts.cli.flags;
45-
var output = flags.output
46-
? path.resolve(flags.output)
47-
: path.join(process.cwd(), input);
42+
var output = flags.output ? path.resolve(flags.output) : path.join(process.cwd(), input);
4843
var targetDir = path.join(dir, "recipes", input);
4944

5045
if (fs.existsSync(output)) {
51-
return opts.cb(
52-
new Error("Target folder exists remove it first and then try again")
53-
);
46+
return opts.cb(new Error("Target folder exists remove it first and then try again"));
5447
}
5548

5649
if (fs.existsSync(targetDir)) {
@@ -59,18 +52,12 @@ module.exports = function(opts) {
5952
opts.cb(err);
6053
} else {
6154
logger.info("Recipe copied into %s", chalk.cyan(output));
62-
logger.info(
63-
"Next, inside that folder, run %s",
64-
chalk.cyan("npm i && npm start")
65-
);
55+
logger.info("Next, inside that folder, run %s", chalk.cyan("npm i && npm start"));
6656
opts.cb(null);
6757
}
6858
});
6959
} else {
70-
logger.info(
71-
"Recipe %s not found. The following are available though",
72-
chalk.cyan(input)
73-
);
60+
logger.info("Recipe %s not found. The following are available though", chalk.cyan(input));
7461
logRecipes();
7562
opts.cb();
7663
}

packages/browser-sync/lib/cli/command.start.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ export default function(opts) {
2626
const conf = require(maybeconf);
2727
input = _.merge({}, conf, flags);
2828
} else {
29-
utils.fail(
30-
true,
31-
new Error(`Configuration file '${flags.config}' not found`),
32-
opts.cb
33-
);
29+
utils.fail(true, new Error(`Configuration file '${flags.config}' not found`), opts.cb);
3430
}
3531
} else {
3632
if (existsSync(maybepkg)) {
@@ -52,11 +48,10 @@ export default function(opts) {
5248
* @returns {*}
5349
*/
5450
function preprocessFlags(flags) {
55-
return [
56-
stripUndefined,
57-
legacyFilesArgs,
58-
removeWatchBooleanWhenFalse
59-
].reduce((flags, fn) => fn.call(null, flags), flags);
51+
return [stripUndefined, legacyFilesArgs, removeWatchBooleanWhenFalse].reduce(
52+
(flags, fn) => fn.call(null, flags),
53+
flags
54+
);
6055
}
6156

6257
/**
@@ -82,10 +77,7 @@ function stripUndefined(subject) {
8277
*/
8378
function legacyFilesArgs(flags) {
8479
if (flags.files && flags.files.length) {
85-
flags.files = flags.files.reduce(
86-
(acc, item) => acc.concat(explodeFilesArg(item)),
87-
[]
88-
);
80+
flags.files = flags.files.reduce((acc, item) => acc.concat(explodeFilesArg(item)), []);
8981
}
9082
return flags;
9183
}

packages/browser-sync/lib/cli/transforms/addDefaultIgnorePatterns.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
import { List } from "immutable";
22
import { BsTempOptions, TransformResult } from "../cli-options";
33

4-
const defaultIgnorePatterns = [
5-
/node_modules/,
6-
/bower_components/,
7-
".sass-cache",
8-
".vscode",
9-
".git",
10-
".idea"
11-
];
4+
const defaultIgnorePatterns = [/node_modules/, /bower_components/, ".sass-cache", ".vscode", ".git", ".idea"];
125

13-
export function addDefaultIgnorePatterns(
14-
incoming: BsTempOptions
15-
): TransformResult {
6+
export function addDefaultIgnorePatterns(incoming: BsTempOptions): TransformResult {
167
if (!incoming.get("watch")) {
178
return [incoming, []];
189
}
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
import { BsTempOptions, TransformResult } from "../cli-options";
22

3-
export function appendServerDirectoryOption(
4-
incoming: BsTempOptions
5-
): TransformResult {
3+
export function appendServerDirectoryOption(incoming: BsTempOptions): TransformResult {
64
if (!incoming.get("server")) return [incoming, []];
75
if (incoming.get("directory")) {
8-
return [
9-
incoming.setIn(["server", "directory"], incoming.has("directory")),
10-
[]
11-
];
6+
return [incoming.setIn(["server", "directory"], incoming.has("directory")), []];
127
}
138
return [incoming, []];
149
}

packages/browser-sync/lib/cli/transforms/appendServerIndexOption.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { BsTempOptions, TransformResult } from "../cli-options";
22

3-
export function appendServerIndexOption(
4-
incoming: BsTempOptions
5-
): TransformResult {
3+
export function appendServerIndexOption(incoming: BsTempOptions): TransformResult {
64
if (!incoming.get("server")) return [incoming, []];
75
const value = incoming.get("index");
86

0 commit comments

Comments
 (0)