From 4da1ee984bb22f9a294deaa79fe77dfc74c12dc7 Mon Sep 17 00:00:00 2001 From: Michael Kowal <35471076+MichaelKowal@users.noreply.github.com> Date: Sun, 16 Oct 2022 04:30:05 -0700 Subject: [PATCH] Check that license file is actually a file (#1231) Co-authored-by: Michael Kowal --- src/license-plugin.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/license-plugin.js b/src/license-plugin.js index 71bea128..ee258a01 100644 --- a/src/license-plugin.js +++ b/src/license-plugin.js @@ -191,7 +191,8 @@ class LicensePlugin { const absolutePath = path.join(dir, '[lL][iI][cC][eE][nN][cCsS][eE]*'); const relativeToCwd = path.relative(cwd, absolutePath); const licenseFile = this._findGlob(relativeToCwd, cwd)[0]; - if (licenseFile) { + // Add the license text if a license file exists + if (fs.existsSync(licenseFile) && fs.lstatSync(licenseFile).isFile()) { pkg.licenseText = fs.readFileSync(licenseFile, 'utf-8'); }