mdv-live 0.5.10 → 0.5.11

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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,23 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.5.11] - 2026-05-09
9
+
10
+ ### Fixed
11
+
12
+ - **Marp PDF export ENOENT in fresh install** (実は 0.5.5 から潜在):
13
+ - `src/api/pdf.js` が marp 実行ファイルを
14
+ `node_modules/mdv-live/node_modules/.bin/marp` で解決していたが、npm
15
+ hoisting により実体は top-level の `node_modules/.bin/marp` にある
16
+ - dev 環境 (mdv-live リポ内) では nested の方が存在するため気づかず、
17
+ `npm install mdv-live` した fresh install では ENOENT
18
+ - `require.resolve('@marp-team/marp-cli/package.json')` から bin スクリプト
19
+ を解決し `node` で実行する方式に変更 (hoist/nest 両対応)
20
+
21
+ ### Tests
22
+
23
+ - 242 → **243 件 (+1)**: marp-cli bin entry の実在チェック regression test
24
+
8
25
  ## [0.5.10] - 2026-05-09
9
26
 
10
27
  ### Fixed (UX revert)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mdv-live",
3
- "version": "0.5.10",
3
+ "version": "0.5.11",
4
4
  "description": "Markdown Viewer - File tree + Live preview + Marp support + Hot reload",
5
5
  "main": "src/server.js",
6
6
  "bin": {
package/src/api/pdf.js CHANGED
@@ -1,19 +1,25 @@
1
1
  import { spawn } from 'child_process';
2
2
  import fs from 'fs/promises';
3
3
  import path from 'path';
4
- import { fileURLToPath } from 'url';
5
4
  import os from 'os';
5
+ import { createRequire } from 'module';
6
6
  import { isMarp } from '../rendering/markdown.js';
7
7
  import { validatePath } from '../utils/path.js';
8
8
 
9
- const marpBin = path.join(
10
- path.dirname(fileURLToPath(import.meta.url)),
11
- '..',
12
- '..',
13
- 'node_modules',
14
- '.bin',
15
- 'marp'
16
- );
9
+ const require = createRequire(import.meta.url);
10
+ // marp-cli は npm hoisting によりインストール先が変わる (top-level / nested)
11
+ // require.resolve でパッケージの実体を特定し、その bin スクリプトを node で
12
+ // 直接実行する。`node_modules/.bin/marp` 直叩きは fresh install で nested
13
+ // パスが無い時に ENOENT する罠。
14
+ const marpEntry = (() => {
15
+ const pkgPath = require.resolve('@marp-team/marp-cli/package.json');
16
+ const pkg = require('@marp-team/marp-cli/package.json');
17
+ const binRel = typeof pkg.bin === 'string' ? pkg.bin : pkg.bin?.marp;
18
+ if (!binRel) {
19
+ throw new Error('@marp-team/marp-cli does not declare a "marp" bin entry');
20
+ }
21
+ return path.join(path.dirname(pkgPath), binRel);
22
+ })();
17
23
  const PDF_EXPORT_TIMEOUT_MS = 180000;
18
24
 
19
25
  /**
@@ -23,7 +29,9 @@ const PDF_EXPORT_TIMEOUT_MS = 180000;
23
29
  */
24
30
  function runMarp(args) {
25
31
  return new Promise((resolve, reject) => {
26
- const child = spawn(marpBin, args, { stdio: ['ignore', 'pipe', 'pipe'] });
32
+ const child = spawn(process.execPath, [marpEntry, ...args], {
33
+ stdio: ['ignore', 'pipe', 'pipe'],
34
+ });
27
35
  let stderr = '';
28
36
  child.stderr.on('data', (chunk) => { stderr += chunk.toString(); });
29
37