File tree 1 file changed +11
-0
lines changed
1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 3
3
import publicGenerators from './generators/index.mjs' ;
4
4
import astJs from './generators/ast-js/index.mjs' ;
5
5
import oramaDb from './generators/orama-db/index.mjs' ;
6
+ import { mkdirSync , statSync } from 'node:fs' ;
6
7
7
8
const availableGenerators = {
8
9
...publicGenerators ,
@@ -51,6 +52,16 @@ const createGenerator = markdownInput => {
51
52
* @param {import('./generators/types.d.ts').GeneratorOptions } options The options for the generator runtime
52
53
*/
53
54
const runGenerators = async ( { generators, ...extra } ) => {
55
+ try {
56
+ if ( ! statSync ( extra . output ) . isDirectory ( ) ) {
57
+ throw new Error ( 'Output is not a directory' ) ;
58
+ }
59
+ } catch ( err ) {
60
+ if ( err . code === 'ENOENT' ) {
61
+ mkdirSync ( extra . output , { recursive : true } ) ;
62
+ }
63
+ }
64
+
54
65
// Note that this method is blocking, and will only execute one generator per-time
55
66
// but it ensures all dependencies are resolved, and that multiple bottom-level generators
56
67
// can reuse the already parsed content from the top-level/dependency generators
You can’t perform that action at this time.
0 commit comments