host-mdx 2.0.0 → 2.0.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.
Files changed (2) hide show
  1. package/index.js +14 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -172,7 +172,14 @@ async function createSite(inputPath, outputPath) {
172
172
  // Iterate through all folders & files
173
173
  const stack = [inputPath];
174
174
  while (stack.length > 0) {
175
+ // Continue if path does not exist
175
176
  const currentPath = stack.pop()
177
+ if(!fs.existsSync(currentPath)){
178
+ continue;
179
+ }
180
+
181
+
182
+ // Get essentials
176
183
  const relToInput = path.relative(inputPath, currentPath)
177
184
  const toIgnore = inputPath != currentPath && ig.ignores(relToInput)
178
185
  const absToOutput = path.join(outputPath, relToInput)
@@ -274,7 +281,7 @@ async function listenForKey(createSiteCallback) {
274
281
  });
275
282
  }
276
283
  function startServer(htmlDir, port) { // Starts server at given port
277
-
284
+
278
285
  // Broadcast server starting
279
286
  configs?.onHostStart?.(port)
280
287
 
@@ -313,6 +320,8 @@ function startServer(htmlDir, port) { // Starts server at given port
313
320
  })
314
321
  newServer.listen(port, () => { log(`Server listening at ${port} ... (Press 'r' to manually reload, Press 'Ctrl+c' to exit)`) })
315
322
  newServer.on("close", () => { configs?.onHostEnd?.(port) });
323
+ newServer.on("error", (e) => { log(`Error Starting server ${e.message}`); throw e; });
324
+
316
325
 
317
326
  return newServer
318
327
  }
@@ -383,7 +392,10 @@ async function Main() {
383
392
 
384
393
  // Watch for changes
385
394
  if (toTrackChanges) {
386
- chokidar.watch(inputPath, { ignoreInitial: true }).on('all', (event, path) => {
395
+ chokidar.watch(inputPath, {
396
+ ignoreInitial: true,
397
+ ignored: (path, stats) => isCreatingSite // Ignore if site creation is ongoing
398
+ }).on('all', (event, path) => {
387
399
  createSiteSafe(inputPath, outputPath)
388
400
  });
389
401
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "host-mdx",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Creates and serves a github pages style html directory from a corresponding mdx directory",
5
5
  "main": "index.js",
6
6
  "type": "module",