Skip to content

Commit

Permalink
chore: dev dependency upgrades (#8)
Browse files Browse the repository at this point in the history
* install pinst
* Upgrade husky to 5.0.9
* Upgrade Jest to 26.6.3
* Upgrade prettier to 2.2.1
* Upgrade pretty-quick to 3.1.0
  • Loading branch information
joebeachjoebeach committed Feb 10, 2021
1 parent 8c90f6a commit 0ab9c83
Show file tree
Hide file tree
Showing 11 changed files with 963 additions and 1,059 deletions.
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PATH=$(npm bin):$PATH pretty-quick --staged
1 change: 1 addition & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[[ \"$(git symbolic-ref --short -q HEAD)\" != \"master\" ]] || npm run try
4 changes: 2 additions & 2 deletions lib/CompilerManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class CompilerManager {

getAllBuildStatuses() {
const result = {};
Object.keys(this.activeCompilers).forEach(name => {
Object.keys(this.activeCompilers).forEach((name) => {
result[name] = this.activeCompilers[name].status;
});
return result;
Expand Down Expand Up @@ -200,7 +200,7 @@ class CompilerManager {
return null;
}
return Object.values(this.activeCompilers)
.filter(compiler => !compiler.pinned)
.filter((compiler) => !compiler.pinned)
.sort((c1, c2) => {
if (this.useFrequency) {
return c2.getFrequency() < c1.getFrequency();
Expand Down
6 changes: 3 additions & 3 deletions lib/ManagedCompiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ManagedCompiler {
});
// This hook fires whenever the compilation fails. We should render errors in
// the console if that's the case.
compiler.hooks.failed.tap(PLUGIN_NAME, error => {
compiler.hooks.failed.tap(PLUGIN_NAME, (error) => {
this.failedCompilation(error);
});
// This hook indicates that a watcher has been closed, and any
Expand Down Expand Up @@ -114,7 +114,7 @@ class ManagedCompiler {
* @param {Error|Array} errors - a list of errors to set.
*/
setStatus(status, errors = []) {
errors = [].concat(errors).filter(error => !!error);
errors = [].concat(errors).filter((error) => !!error);
const statuses = [FIRST_BUILD, BUILDING, ERROR, DONE];
if (!statuses.includes(status)) {
throw `${status} is not a valid status for a compiler. Valid statuses include: ${statuses.join(
Expand All @@ -136,7 +136,7 @@ class ManagedCompiler {
* @param {Array<Error>} errors
*/
setCurrentErrors(errors) {
this.lastErrors = errors.map(err => err.stack);
this.lastErrors = errors.map((err) => err.stack);
}

getCurrentErrors() {
Expand Down
6 changes: 3 additions & 3 deletions lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const colorFgBlue = "\x1b[34m";
* that you'd like to see if you were reading through the logs after the fact.
* @param {string} msg — this is what gets logged
*/
const logInfo = function(msg) {
const logInfo = function (msg) {
// eslint-disable-next-line no-console
console.log(` ${colorFgBlue}[KEVIN]${colorReset} ${msg}${colorReset}`);
};
Expand All @@ -25,15 +25,15 @@ const logInfo = function(msg) {
* just started).
* @param {string} msg — this is what gets logged
*/
const logNotice = function(msg) {
const logNotice = function (msg) {
logInfo(`${colorBright + colorFgYellow}${msg}`);
};

/**
* Use this method for errors, or things that imply something unexpected has happened.
* @param {string} msg — this is what gets logged
*/
const logError = function(err) {
const logError = function (err) {
// eslint-disable-next-line no-console
console.error(` ${colorFgRed}[KEVIN]${colorReset}`, err);
};
Expand Down
14 changes: 7 additions & 7 deletions lib/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Kevin {
maxCompilers = 3,
// Given a request path, return the name of the asset we're trying to serve.
// Useful if you have entries that don't map to the filenames they render.
getAssetName = path => path,
getAssetName = (path) => path,
// Only build assets; don't handle serving them. This is useful if you want to do
// something with the built asset before serving it.
buildOnly = false,
Expand Down Expand Up @@ -96,7 +96,7 @@ class Kevin {
if (!configName) {
return null;
}
const config = configs.find(config => {
const config = configs.find((config) => {
return config.name === configName;
});
// Array.find returns undefined, not null, if nothing matches
Expand All @@ -111,7 +111,7 @@ class Kevin {
* build of a new compiler (true) or a rebuild of an existing one (false)
*/
buildConfig(configName) {
const config = this.configs.find(config => config.name === configName);
const config = this.configs.find((config) => config.name === configName);
if (!config) {
logError(`Trying to build config: ${configName}, but it can't be found.`);
}
Expand Down Expand Up @@ -167,7 +167,7 @@ class Kevin {
aggregateTimeout: 1000,
poll: undefined,
},
err => {
(err) => {
if (err !== null) {
err && logError(err);
manager.setStatus(configName, ERROR, [err]);
Expand Down Expand Up @@ -225,7 +225,7 @@ class Kevin {
// like "wow you're evicting a lot. you may want to rebalance your entries or
// increase your limit"
// TODO: Also make sure there are no outstanding callbacks!!
return manager.closeCompiler(options.compilerToEvict).then(name => {
return manager.closeCompiler(options.compilerToEvict).then((name) => {
logNotice(
`We stopped compiling ${compilerToEvict} to free some resources.`
);
Expand Down Expand Up @@ -303,7 +303,7 @@ class Kevin {
logInfo("╘═════════════════════════════╛");
logInfo("");
logInfo("This middleware is currently managing the following configs:");
this.configs.forEach(config => {
this.configs.forEach((config) => {
logInfo(`\t• ${config.name}`);
});
logInfo("");
Expand Down Expand Up @@ -373,7 +373,7 @@ class Kevin {
configName,
});
})
.catch(err => {
.catch((err) => {
this.serveError({ res, configName, assetName, err });
return;
});
Expand Down
16 changes: 9 additions & 7 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const { logError } = require("./logger");
* promises externally by exposing references to a promise's `resolve` and `reject`.
* @return {function} a deferred factory function
*/
const defer = function() {
const defer = function () {
let resolve;
let reject;
const promise = new Promise((res, rej) => {
Expand All @@ -30,7 +30,7 @@ const defer = function() {
* @param {string} path - a request path (i.e. from express's req.path)
* @return {string} the location of the file on disk
*/
const getPathToServe = function(compiler, reqPath) {
const getPathToServe = function (compiler, reqPath) {
const outputPath = compiler.options.output.path;
const publicPath = compiler.options.output.publicPath;

Expand Down Expand Up @@ -75,11 +75,13 @@ const getPathToServe = function(compiler, reqPath) {
* @throws {Error} if config names are missing or non-unique
* @returns {array} - an array of webpack configs
*/
const validateConfigs = function(configs) {
const validateConfigs = function (configs) {
// Ensure the configs are an array (webpack configs can be one object)
const configArray = [].concat(configs);
// Make a list of all names, filtering out undefined and null names
const configNames = configArray.map(config => config.name).filter(name => !!name);
const configNames = configArray
.map((config) => config.name)
.filter((name) => !!name);

if (configNames.length !== configArray.length) {
throw new Error(
Expand Down Expand Up @@ -107,9 +109,9 @@ const validateConfigs = function(configs) {
* That may be extreme, but if it is we can fix it when it becomes a problem.
* @param {array} configs
*/
const initializeEntryMap = function(configs) {
const initializeEntryMap = function (configs) {
const entryMap = {};
configs.forEach(config => {
configs.forEach((config) => {
const { name: configName, entry } = config;
if (!entry) {
logError(`Config "${configName}" doesn't have the "entry" key set`);
Expand All @@ -126,7 +128,7 @@ const initializeEntryMap = function(configs) {
}
entryMap.main = configName;
} else {
Object.keys(entry).forEach(key => {
Object.keys(entry).forEach((key) => {
if (entryMap[key]) {
throw new Error(
`Entrypoint ${key} is built by both ${entryMap[key]} ` +
Expand Down

0 comments on commit 0ab9c83

Please sign in to comment.