File tree 1 file changed +12
-0
lines changed
1 file changed +12
-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,17 @@ 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
+ // console.log('Output is a directory')
59
+ }
60
+ } catch ( err ) {
61
+ if ( err . code === 'ENOENT' ) {
62
+ mkdirSync ( extra . output , { recursive : true } ) ;
63
+ }
64
+ }
65
+
54
66
// Note that this method is blocking, and will only execute one generator per-time
55
67
// but it ensures all dependencies are resolved, and that multiple bottom-level generators
56
68
// can reuse the already parsed content from the top-level/dependency generators
You can’t perform that action at this time.
0 commit comments