Browse Source

fix(create): Fix broken bootstrap when populating data

Michael Bromley 4 years ago
parent
commit
5dcf6e52b5
1 changed files with 11 additions and 15 deletions
  1. 11 15
      packages/create/src/create-vendure-app.ts

+ 11 - 15
packages/create/src/create-vendure-app.ts

@@ -43,7 +43,7 @@ program
     })
     .option(
         '--log-level <logLevel>',
-        "Log level, either 'silent', 'info', or 'verbose'",
+        `Log level, either 'silent', 'info', or 'verbose'`,
         /^(silent|info|verbose)$/i,
         'silent',
     )
@@ -217,6 +217,7 @@ async function createApp(
                             : logLevel === 'verbose'
                             ? LogLevel.Verbose
                             : LogLevel.Info;
+
                     const bootstrapFn = async () => {
                         await checkDbConnection(config.dbConnectionOptions, root);
                         const _app = await bootstrap({
@@ -231,25 +232,20 @@ async function createApp(
                                 synchronize: true,
                             },
                             logger: new DefaultLogger({ level: vendureLogLevel }),
-                            workerOptions: {
-                                runInMainProcess: true,
-                            },
                             importExportOptions: {
                                 importAssetsDir: path.join(assetsDir, 'images'),
                             },
                         });
-                        _app.get(JobQueueService).start();
+                        await _app.get(JobQueueService).start();
+                        return _app;
                     };
-                    let app: any;
-                    if (populateProducts) {
-                        app = await populate(
-                            bootstrapFn,
-                            initialDataPath,
-                            path.join(assetsDir, 'products.csv'),
-                        );
-                    } else {
-                        app = await populate(bootstrapFn, initialDataPath);
-                    }
+
+                    const app = await populate(
+                        bootstrapFn,
+                        initialDataPath,
+                        populateProducts ? path.join(assetsDir, 'products.csv') : undefined,
+                    );
+
                     // Pause to ensure the worker jobs have time to complete.
                     if (isCi) {
                         console.log('[CI] Pausing before close...');