lemonppt 0.2.2 → 0.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.
- package/cli.js +13 -3
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -9,10 +9,20 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { spawnSync } from 'node:child_process';
|
|
12
|
-
import {
|
|
12
|
+
import { readFileSync } from 'node:fs';
|
|
13
|
+
import path from 'node:path';
|
|
14
|
+
import { fileURLToPath } from 'node:url';
|
|
13
15
|
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
+
const mainUrl = import.meta.resolve('@lemonppt/cli');
|
|
17
|
+
const mainPath = fileURLToPath(mainUrl);
|
|
18
|
+
const pkgDir = path.resolve(mainPath, '..', '..');
|
|
19
|
+
const cliPkg = JSON.parse(readFileSync(path.join(pkgDir, 'package.json'), 'utf-8'));
|
|
20
|
+
const binEntry = typeof cliPkg.bin === 'string' ? cliPkg.bin : cliPkg.bin?.lemonppt;
|
|
21
|
+
if (!binEntry) {
|
|
22
|
+
console.error('无法定位 @lemonppt/cli 的 bin 入口');
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
const cliPath = path.join(pkgDir, binEntry);
|
|
16
26
|
|
|
17
27
|
const result = spawnSync(
|
|
18
28
|
process.execPath,
|