rolldown-license-plugin 2.2.2 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +6 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { readFile, readdir } from "node:fs/promises";
2
- import { join } from "node:path";
2
+ import { join, sep } from "node:path";
3
3
 
4
4
  //#region index.ts
5
5
  const defaultMatch = /^((UN)?LICEN(S|C)E|COPYING).*$/i;
@@ -41,18 +41,19 @@ function parseLicense(pkgJson) {
41
41
  const nmSep = "/node_modules/";
42
42
  /** Resolve the package root directory from a file path inside node_modules */
43
43
  function findPkgRoot(fsPath) {
44
- const nmIdx = fsPath.lastIndexOf(nmSep);
44
+ const p = sep !== "/" ? fsPath.replaceAll(sep, "/") : fsPath;
45
+ const nmIdx = p.lastIndexOf(nmSep);
45
46
  if (nmIdx === -1) return null;
46
47
  const base = nmIdx + 14;
47
- const rest = fsPath.slice(base);
48
+ const rest = p.slice(base);
48
49
  if (rest.startsWith("@")) {
49
50
  const firstSlash = rest.indexOf("/");
50
51
  if (firstSlash === -1) return null;
51
52
  const secondSlash = rest.indexOf("/", firstSlash + 1);
52
- return fsPath.slice(0, base) + rest.slice(0, secondSlash === -1 ? rest.length : secondSlash);
53
+ return p.slice(0, base) + rest.slice(0, secondSlash === -1 ? rest.length : secondSlash);
53
54
  }
54
55
  const firstSlash = rest.indexOf("/");
55
- return fsPath.slice(0, base) + rest.slice(0, firstSlash === -1 ? rest.length : firstSlash);
56
+ return p.slice(0, base) + rest.slice(0, firstSlash === -1 ? rest.length : firstSlash);
56
57
  }
57
58
  /** Rolldown plugin that extracts license information from bundled dependencies */
58
59
  const licensePlugin = ({ done, match = defaultMatch, wrapText, allow, failOnViolation = false, failOnUnlicensed = false }) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rolldown-license-plugin",
3
- "version": "2.2.2",
3
+ "version": "2.2.3",
4
4
  "description": "Rolldown plugin to extract dependency licenses",
5
5
  "author": "silverwind <me@silverwind.io>",
6
6
  "repository": "silverwind/rolldown-license-plugin",