@boy-offi9-inc/tidepull 0.17.0 → 0.17.1

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.
@@ -43,12 +43,14 @@ export async function pluginInstall(pkg, pluginDir, log, env = process.env) {
43
43
  }
44
44
  const entry = pluginEntryFile(pkgDir);
45
45
  const stagePkg = path.join(staging, safe, "package.json");
46
- if (!existsSync(stagePkg)) {
47
- try {
48
- writeFileSync(stagePkg, JSON.stringify({ type: "module" }) + "\n");
46
+ try {
47
+ const meta2 = existsSync(stagePkg) ? JSON.parse(readFileSync(stagePkg, "utf8")) : {};
48
+ if (meta2.type !== "module") {
49
+ meta2.type = "module";
50
+ writeFileSync(stagePkg, JSON.stringify(meta2) + "\n");
49
51
  }
50
- catch { }
51
52
  }
53
+ catch { }
52
54
  const work = path.join(staging, safe, name.split("/").pop().replace(/[^\w.-]/g, "_") + path.extname(entry));
53
55
  copyFileSync(entry, work);
54
56
  const dest = path.join(pluginDir, name.split("/").pop().replace(/[^.\w-]/g, "_") + path.extname(entry));
package/dist/loader.js CHANGED
@@ -55,12 +55,26 @@ function ensureModuleType(dir) {
55
55
  }
56
56
  export async function loadPlugins(paths) {
57
57
  const out = [];
58
+ const seen = new Map();
59
+ const warn = (msg) => { try {
60
+ process.stderr.write(`WARNING: ${msg}\n`);
61
+ }
62
+ catch { } };
63
+ const keep = (p, file) => {
64
+ const prev = seen.get(p.name);
65
+ if (prev !== undefined) {
66
+ warn(`duplicate plugin "${p.name}": ${file} ignored — already loaded from ${prev} (remove one of the two files)`);
67
+ return;
68
+ }
69
+ seen.set(p.name, file);
70
+ out.push(p);
71
+ };
58
72
  for (const p of paths) {
59
73
  const s = await stat(p).catch(() => undefined);
60
74
  if (!s)
61
75
  throw new TidepullError(`Plugin path not found: ${p}`);
62
76
  if (s.isFile()) {
63
- out.push(await loadPlugin(p));
77
+ keep(await loadPlugin(p), p);
64
78
  continue;
65
79
  }
66
80
  ensureModuleType(p);
@@ -70,11 +84,11 @@ export async function loadPlugins(paths) {
70
84
  const full = path.join(p, name);
71
85
  const fs = await stat(full);
72
86
  if (fs.isFile() && FILE_RE.test(name))
73
- out.push(await loadPlugin(full));
87
+ keep(await loadPlugin(full), full);
74
88
  else if (fs.isDirectory()) {
75
89
  const idx = (await readdir(full)).find((f) => INDEX_RE.test(f));
76
90
  if (idx)
77
- out.push(await loadPlugin(path.join(full, idx)));
91
+ keep(await loadPlugin(path.join(full, idx)), path.join(full, idx));
78
92
  }
79
93
  }
80
94
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boy-offi9-inc/tidepull",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "description": "A minimal, from-scratch media downloader library: extractor plugins, yt-dlp-style format selection, resumable downloads.",
5
5
  "type": "module",
6
6
  "license": "MIT",