Skip to content

Commit

Permalink
Merge pull request #246 from webpack/deps/upgrade
Browse files Browse the repository at this point in the history
update dependencies
  • Loading branch information
sokra committed Sep 17, 2020
2 parents aa18aea + 4d4cd2e commit 87df621
Show file tree
Hide file tree
Showing 24 changed files with 1,680 additions and 2,635 deletions.
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package.json
test/**/*.*
!test/*.js
2 changes: 2 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module.exports = {
printWidth: 80,
useTabs: true,
tabWidth: 2,
trailingComma: "none",
arrowParens: "avoid",
overrides: [
{
files: "*.json",
Expand Down
30 changes: 20 additions & 10 deletions lib/CachedInputFileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,26 +377,32 @@ module.exports = class CachedInputFileSystem {
this.fileSystem.statSync,
this.fileSystem
);
this.stat = /** @type {FileSystem["stat"]} */ (this._statBackend.provide);
this.statSync = /** @type {SyncFileSystem["statSync"]} */ (this._statBackend.provideSync);
const stat = this._statBackend.provide;
this.stat = /** @type {FileSystem["stat"]} */ (stat);
const statSync = this._statBackend.provideSync;
this.statSync = /** @type {SyncFileSystem["statSync"]} */ (statSync);

this._readdirBackend = createBackend(
duration,
this.fileSystem.readdir,
this.fileSystem.readdirSync,
this.fileSystem
);
this.readdir = /** @type {FileSystem["readdir"]} */ (this._readdirBackend.provide);
this.readdirSync = /** @type {SyncFileSystem["readdirSync"]} */ (this._readdirBackend.provideSync);
const readdir = this._readdirBackend.provide;
this.readdir = /** @type {FileSystem["readdir"]} */ (readdir);
const readdirSync = this._readdirBackend.provideSync;
this.readdirSync = /** @type {SyncFileSystem["readdirSync"]} */ (readdirSync);

this._readFileBackend = createBackend(
duration,
this.fileSystem.readFile,
this.fileSystem.readFileSync,
this.fileSystem
);
this.readFile = /** @type {FileSystem["readFile"]} */ (this._readFileBackend.provide);
this.readFileSync = /** @type {SyncFileSystem["readFileSync"]} */ (this._readFileBackend.provideSync);
const readFile = this._readFileBackend.provide;
this.readFile = /** @type {FileSystem["readFile"]} */ (readFile);
const readFileSync = this._readFileBackend.provideSync;
this.readFileSync = /** @type {SyncFileSystem["readFileSync"]} */ (readFileSync);

this._readJsonBackend = createBackend(
duration,
Expand Down Expand Up @@ -426,17 +432,21 @@ module.exports = class CachedInputFileSystem {
})),
this.fileSystem
);
this.readJson = /** @type {FileSystem["readJson"]} */ (this._readJsonBackend.provide);
this.readJsonSync = /** @type {SyncFileSystem["readJsonSync"]} */ (this._readJsonBackend.provideSync);
const readJson = this._readJsonBackend.provide;
this.readJson = /** @type {FileSystem["readJson"]} */ (readJson);
const readJsonSync = this._readJsonBackend.provideSync;
this.readJsonSync = /** @type {SyncFileSystem["readJsonSync"]} */ (readJsonSync);

this._readlinkBackend = createBackend(
duration,
this.fileSystem.readlink,
this.fileSystem.readlinkSync,
this.fileSystem
);
this.readlink = /** @type {FileSystem["readlink"]} */ (this._readlinkBackend.provide);
this.readlinkSync = /** @type {SyncFileSystem["readlinkSync"]} */ (this._readlinkBackend.provideSync);
const readlink = this._readlinkBackend.provide;
this.readlink = /** @type {FileSystem["readlink"]} */ (readlink);
const readlinkSync = this._readlinkBackend.provideSync;
this.readlinkSync = /** @type {SyncFileSystem["readlinkSync"]} */ (readlinkSync);
}

purge(what) {
Expand Down
11 changes: 8 additions & 3 deletions lib/ResolverFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const UseFilePlugin = require("./UseFilePlugin");
/** @typedef {import("./PnpPlugin").PnpApiImpl} PnpApi */
/** @typedef {import("./Resolver").FileSystem} FileSystem */
/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */
/** @typedef {import("./Resolver").SyncFileSystem} SyncFileSystem */

/** @typedef {string|string[]|false} AliasOptionNewRequest */
/** @typedef {{[k: string]: AliasOptionNewRequest}} AliasOptions */
Expand Down Expand Up @@ -171,7 +172,7 @@ function createOptions(options) {
aliasFields: new Set(options.aliasFields),
cachePredicate:
options.cachePredicate ||
function() {
function () {
return true;
},
cacheWithContext:
Expand All @@ -187,7 +188,11 @@ function createOptions(options) {
enforceExtension: options.enforceExtension || false,
extensions: new Set(options.extensions || [".js", ".json", ".node"]),
fileSystem: options.useSyncFileSystemCalls
? new SyncAsyncFileSystemDecorator(options.fileSystem)
? new SyncAsyncFileSystemDecorator(
/** @type {SyncFileSystem} */ (
/** @type {unknown} */ (options.fileSystem)
)
)
: options.fileSystem,
unsafeCache:
options.unsafeCache && typeof options.unsafeCache !== "object"
Expand Down Expand Up @@ -221,7 +226,7 @@ function createOptions(options) {
* @param {UserResolveOptions} options resolve options
* @returns {Resolver} created resolver
*/
exports.createResolver = function(options) {
exports.createResolver = function (options) {
const normalizedOptions = createOptions(options);

const {
Expand Down
105 changes: 50 additions & 55 deletions lib/SyncAsyncFileSystemDecorator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,79 +5,74 @@

"use strict";

/** @typedef {import("./Resolver").FileSystem} FileSystem */
/** @typedef {import("./Resolver").SyncFileSystem} SyncFileSystem */

/**
* @param {Object} fs file system implementation
* @param {SyncFileSystem} fs file system implementation
* @constructor
*/
function SyncAsyncFileSystemDecorator(fs) {
/**
* @type {Object}
*/
this.fs = fs;
if (fs.statSync) {
this.stat = (arg, callback) => {
let result;
try {
result = fs.statSync(arg);
} catch (e) {
return callback(e);
}
callback(null, result);
};
this.stat = (arg, callback) => {
let result;
try {
result = fs.statSync(arg);
} catch (e) {
return callback(e);
}
callback(null, result);
};
this.statSync = arg => fs.statSync(arg);

this.statSync = arg => fs.statSync(arg);
}
if (fs.readdirSync) {
this.readdir = (arg, callback) => {
let result;
try {
result = fs.readdirSync(arg);
} catch (e) {
return callback(e);
}
callback(null, result);
};
this.readdir = (arg, callback) => {
let result;
try {
result = fs.readdirSync(arg);
} catch (e) {
return callback(e);
}
callback(null, result);
};
this.readdirSync = arg => fs.readdirSync(arg);

this.readdirSync = arg => fs.readdirSync(arg);
}
if (fs.readFileSync) {
this.readFile = (arg, callback) => {
let result;
try {
result = fs.readFileSync(arg);
} catch (e) {
return callback(e);
}
callback(null, result);
};
this.readFile = (arg, callback) => {
let result;
try {
result = fs.readFileSync(arg);
} catch (e) {
return callback(e);
}
callback(null, result);
};
this.readFileSync = arg => fs.readFileSync(arg);

this.readFileSync = arg => fs.readFileSync(arg);
}
if (fs.readlinkSync) {
this.readlink = (arg, callback) => {
let result;
try {
result = fs.readlinkSync(arg);
} catch (e) {
return callback(e);
}
callback(null, result);
};
this.readlink = (arg, callback) => {
let result;
try {
result = fs.readlinkSync(arg);
} catch (e) {
return callback(e);
}
callback(null, result);
};
this.readlinkSync = arg => fs.readlinkSync(arg);

this.readlinkSync = arg => fs.readlinkSync(arg);
}
if (fs.readJsonSync) {
this.readJson = undefined;
this.readJsonSync = undefined;
const readJsonSync = fs.readJsonSync;
if (readJsonSync) {
this.readJson = (arg, callback) => {
let result;
try {
result = fs.readJsonSync(arg);
result = readJsonSync.call(fs, arg);
} catch (e) {
return callback(e);
}
callback(null, result);
};

this.readJsonSync = arg => fs.readJsonSync(arg);
this.readJsonSync = arg => readJsonSync.call(fs, arg);
}
}
module.exports = SyncAsyncFileSystemDecorator;
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function create(options) {
...options
};
const resolver = ResolverFactory.createResolver(options);
return function(context, path, request, resolveContext, callback) {
return function (context, path, request, resolveContext, callback) {
if (typeof context === "string") {
callback = resolveContext;
resolveContext = request;
Expand All @@ -85,7 +85,7 @@ function createSync(options) {
...options
};
const resolver = ResolverFactory.createResolver(options);
return function(context, path, request) {
return function (context, path, request) {
if (typeof context === "string") {
request = path;
path = context;
Expand Down
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@
"LICENSE"
],
"dependencies": {
"graceful-fs": "^4.2.0",
"tapable": "^2.0.0-beta.10"
"graceful-fs": "^4.2.4",
"tapable": "^2.0.0"
},
"license": "MIT",
"devDependencies": {
"@types/mocha": "^7.0.2",
"@types/node": "^13.7.7",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-jsdoc": "^22.0.0",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prettier": "^3.1.2",
"husky": "^1.2.0",
"lint-staged": "^8.1.0",
"memfs": "^2.15.4",
"mocha": "^7.1.0",
"nyc": "^14.1.1",
"prettier": "^1.15.2",
"@types/mocha": "^8.0.3",
"@types/node": "^14.11.1",
"eslint": "^7.9.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-jsdoc": "^30.5.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.1.4",
"husky": "^4.3.0",
"lint-staged": "^10.4.0",
"memfs": "^3.2.0",
"mocha": "^8.1.3",
"nyc": "^15.1.0",
"prettier": "^2.1.2",
"should": "^13.2.3",
"tooling": "webpack/tooling#v1.6.0",
"typescript": "^3.8.3"
"tooling": "webpack/tooling#v1.8.0",
"typescript": "^4.0.2"
},
"engines": {
"node": ">=10.13.0"
Expand All @@ -45,7 +45,7 @@
"type-lint": "tsc",
"special-lint": "node node_modules/tooling/lockfile-lint && node node_modules/tooling/inherit-types && node node_modules/tooling/format-file-header && node node_modules/tooling/generate-types",
"special-lint-fix": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/format-file-header --write && node node_modules/tooling/generate-types --write",
"pretty": "prettier --loglevel warn --write \"{lib,test}/**/*.{js,json}\"",
"pretty": "prettier --loglevel warn --write \"lib/**/*.{js,json}\" \"test/*.js\"",
"pretest": "yarn lint",
"test": "mocha --full-trace --check-leaks",
"precover": "yarn lint",
Expand Down

0 comments on commit 87df621

Please sign in to comment.