source: trip-planner-front/node_modules/license-webpack-plugin/dist/PluginChunkReadHandler.js@ 1ad8e64

Last change on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.3 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.PluginChunkReadHandler = void 0;
4var WebpackChunkModuleIterator_1 = require("./WebpackChunkModuleIterator");
5var WebpackModuleFileIterator_1 = require("./WebpackModuleFileIterator");
6var PluginChunkReadHandler = /** @class */ (function () {
7 function PluginChunkReadHandler(logger, fileHandler, licenseTypeIdentifier, licenseTextReader, licensePolicy, fileSystem) {
8 this.logger = logger;
9 this.fileHandler = fileHandler;
10 this.licenseTypeIdentifier = licenseTypeIdentifier;
11 this.licenseTextReader = licenseTextReader;
12 this.licensePolicy = licensePolicy;
13 this.fileSystem = fileSystem;
14 this.moduleIterator = new WebpackChunkModuleIterator_1.WebpackChunkModuleIterator();
15 this.fileIterator = new WebpackModuleFileIterator_1.WebpackModuleFileIterator(require.resolve);
16 }
17 PluginChunkReadHandler.prototype.processChunk = function (compilation, chunk, moduleCache, stats) {
18 var _this = this;
19 this.moduleIterator.iterateModules(compilation, chunk, stats, function (module) {
20 _this.fileIterator.iterateFiles(module, function (filename) {
21 var module = _this.fileHandler.getModule(filename);
22 _this.processModule(compilation, chunk, moduleCache, module);
23 });
24 });
25 };
26 PluginChunkReadHandler.prototype.getPackageJson = function (directory) {
27 var filename = "" + directory + this.fileSystem.pathSeparator + "package.json";
28 return JSON.parse(this.fileSystem.readFileAsUtf8(filename));
29 };
30 PluginChunkReadHandler.prototype.processModule = function (compilation, chunk, moduleCache, module) {
31 var _a;
32 if (module && !moduleCache.alreadySeenForChunk(chunk.name, module.name)) {
33 var alreadyIncludedModule = moduleCache.getModule(module.name);
34 if (alreadyIncludedModule !== null) {
35 moduleCache.registerModule(chunk.name, alreadyIncludedModule);
36 }
37 else {
38 // module not yet in cache
39 var packageJson = (_a = module.packageJson) !== null && _a !== void 0 ? _a : this.getPackageJson(module.directory);
40 var licenseType = this.licenseTypeIdentifier.findLicenseIdentifier(compilation, module.name, packageJson);
41 if (this.licensePolicy.isLicenseUnacceptableFor(licenseType)) {
42 this.logger.error(compilation, "unacceptable license found for " + module.name + ": " + licenseType);
43 this.licensePolicy.handleUnacceptableLicense(module.name, licenseType);
44 }
45 if (this.licensePolicy.isLicenseWrittenFor(licenseType)) {
46 var licenseText = this.licenseTextReader.readLicense(compilation, module, licenseType);
47 moduleCache.registerModule(chunk.name, {
48 licenseText: licenseText,
49 packageJson: packageJson,
50 name: module.name,
51 directory: module.directory,
52 licenseId: licenseType
53 });
54 }
55 }
56 moduleCache.markSeenForChunk(chunk.name, module.name);
57 }
58 };
59 return PluginChunkReadHandler;
60}());
61exports.PluginChunkReadHandler = PluginChunkReadHandler;
Note: See TracBrowser for help on using the repository browser.