diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
commit | bbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch) | |
tree | c58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/enhanced-resolve/lib/FileExistsPlugin.js | |
parent | 003fb34971cf63466184351b4db5f7c67df4f444 (diff) |
update packages
Diffstat (limited to 'node_modules/enhanced-resolve/lib/FileExistsPlugin.js')
-rw-r--r-- | node_modules/enhanced-resolve/lib/FileExistsPlugin.js | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/node_modules/enhanced-resolve/lib/FileExistsPlugin.js b/node_modules/enhanced-resolve/lib/FileExistsPlugin.js index 59fc6a5f1..0fa3aa1de 100644 --- a/node_modules/enhanced-resolve/lib/FileExistsPlugin.js +++ b/node_modules/enhanced-resolve/lib/FileExistsPlugin.js @@ -2,29 +2,32 @@ MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
-function FileExistsPlugin(source, target) {
- this.source = source;
- this.target = target;
-}
-module.exports = FileExistsPlugin;
+"use strict";
-FileExistsPlugin.prototype.apply = function(resolver) {
- var target = this.target;
- resolver.plugin(this.source, function(request, callback) {
- var fs = this.fileSystem;
- var file = request.path;
- fs.stat(file, function(err, stat) {
- if(err || !stat) {
- if(callback.missing) callback.missing.push(file);
- if(callback.log) callback.log(file + " doesn't exist");
- return callback();
- }
- if(!stat.isFile()) {
- if(callback.missing) callback.missing.push(file);
- if(callback.log) callback.log(file + " is not a file");
- return callback();
- }
- this.doResolve(target, request, "existing file: " + file, callback, true);
- }.bind(this));
- });
+module.exports = class FileExistsPlugin {
+ constructor(source, target) {
+ this.source = source;
+ this.target = target;
+ }
+
+ apply(resolver) {
+ const target = resolver.ensureHook(this.target);
+ const fs = resolver.fileSystem;
+ resolver.getHook(this.source).tapAsync("FileExistsPlugin", (request, resolveContext, callback) => {
+ const file = request.path;
+ fs.stat(file, (err, stat) => {
+ if(err || !stat) {
+ if(resolveContext.missing) resolveContext.missing.add(file);
+ if(resolveContext.log) resolveContext.log(file + " doesn't exist");
+ return callback();
+ }
+ if(!stat.isFile()) {
+ if(resolveContext.missing) resolveContext.missing.add(file);
+ if(resolveContext.log) resolveContext.log(file + " is not a file");
+ return callback();
+ }
+ resolver.doResolve(target, request, "existing file: " + file, resolveContext, callback);
+ });
+ });
+ }
};
|