From bbff7403fbf46f9ad92240ac213df8d30ef31b64 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 20 Sep 2018 02:56:13 +0200 Subject: update packages --- .../enhanced-resolve/lib/FileExistsPlugin.js | 51 ++++++++++++---------- 1 file changed, 27 insertions(+), 24 deletions(-) (limited to 'node_modules/enhanced-resolve/lib/FileExistsPlugin.js') 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); + }); + }); + } }; -- cgit v1.2.3