vimd 0.1.5 → 0.1.6
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/dev.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/dev.ts"],"names":[],"mappings":"AAWA,UAAU,UAAU;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,IAAI,CAAC,CAwGf"}
|
package/dist/cli/commands/dev.js
CHANGED
|
@@ -6,7 +6,6 @@ import { LiveServer } from '../../core/server.js';
|
|
|
6
6
|
import { PandocDetector } from '../../core/pandoc-detector.js';
|
|
7
7
|
import { Logger } from '../../utils/logger.js';
|
|
8
8
|
import { ProcessManager } from '../../utils/process-manager.js';
|
|
9
|
-
import { TempManager } from '../../utils/temp-manager.js';
|
|
10
9
|
import * as path from 'path';
|
|
11
10
|
import fs from 'fs-extra';
|
|
12
11
|
export async function devCommand(filePath, options) {
|
|
@@ -34,9 +33,11 @@ export async function devCommand(filePath, options) {
|
|
|
34
33
|
Logger.error(`File not found: ${filePath}`);
|
|
35
34
|
process.exit(1);
|
|
36
35
|
}
|
|
37
|
-
// 4. Prepare output
|
|
38
|
-
const
|
|
39
|
-
const
|
|
36
|
+
// 4. Prepare output HTML in source directory
|
|
37
|
+
const sourceDir = path.dirname(absolutePath);
|
|
38
|
+
const basename = path.basename(filePath, path.extname(filePath));
|
|
39
|
+
const htmlFileName = `vimd-preview-${basename}.html`;
|
|
40
|
+
const htmlPath = path.join(sourceDir, htmlFileName);
|
|
40
41
|
// 5. Prepare converter
|
|
41
42
|
const converter = new MarkdownConverter({
|
|
42
43
|
theme: config.theme,
|
|
@@ -49,12 +50,12 @@ export async function devCommand(filePath, options) {
|
|
|
49
50
|
const html = await converter.convertWithTemplate(absolutePath);
|
|
50
51
|
await converter.writeHTML(html, htmlPath);
|
|
51
52
|
Logger.success('Conversion complete');
|
|
52
|
-
// 7. Start live server
|
|
53
|
+
// 7. Start live server from source directory
|
|
53
54
|
const server = new LiveServer({
|
|
54
55
|
port: config.port,
|
|
55
56
|
host: config.host,
|
|
56
57
|
open: config.open,
|
|
57
|
-
root:
|
|
58
|
+
root: sourceDir,
|
|
58
59
|
});
|
|
59
60
|
await server.start(htmlPath);
|
|
60
61
|
Logger.info(`Watching: ${filePath}`);
|
|
@@ -76,12 +77,19 @@ export async function devCommand(filePath, options) {
|
|
|
76
77
|
}
|
|
77
78
|
});
|
|
78
79
|
watcher.start();
|
|
79
|
-
// 9. Register cleanup
|
|
80
|
+
// 9. Register cleanup - remove generated HTML file
|
|
80
81
|
ProcessManager.onExit(async () => {
|
|
81
82
|
Logger.info('Shutting down...');
|
|
82
83
|
await watcher.stop();
|
|
83
84
|
await server.stop();
|
|
84
|
-
|
|
85
|
+
// Remove the generated preview HTML file
|
|
86
|
+
try {
|
|
87
|
+
await fs.remove(htmlPath);
|
|
88
|
+
Logger.info(`Removed: ${htmlFileName}`);
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
// Ignore errors when removing file
|
|
92
|
+
}
|
|
85
93
|
Logger.info('Cleanup complete');
|
|
86
94
|
});
|
|
87
95
|
}
|
package/dist/config/defaults.js
CHANGED
package/dist/core/server.js
CHANGED