Pārlūkot izejas kodu

refactor(core): Remove redundant argument of populate() function

Michael Bromley 6 gadi atpakaļ
vecāks
revīzija
95bf9a79a2

+ 5 - 12
packages/core/cli/populate.ts

@@ -15,21 +15,14 @@ try {
 }
 
 // tslint:disable:no-console
-export async function populate(
-    bootstrapFn: () => Promise<INestApplication | undefined>,
-    initialDataPath: string,
-): Promise<INestApplication>;
-export async function populate(
-    bootstrapFn: () => Promise<INestApplication | undefined>,
-    initialDataPath: string,
-    productsCsvPath: string,
-    imageSourcePath: string,
-): Promise<INestApplication>;
+/**
+ * Populates the Vendure server with some initial data and (optionally) product data from
+ * a supplied CSV file.
+ */
 export async function populate(
     bootstrapFn: () => Promise<INestApplication | undefined>,
     initialDataPath: string,
     productsCsvPath?: string,
-    imageSourcePath?: string,
 ): Promise<INestApplication> {
     const app = await bootstrapFn();
     if (!app) {
@@ -37,7 +30,7 @@ export async function populate(
     }
     const initialData = require(initialDataPath);
     await populateInitialData(app, initialData);
-    if (productsCsvPath && imageSourcePath) {
+    if (productsCsvPath) {
         await importProductsFromFile(app, productsCsvPath, initialData.defaultLanguage);
         await populateCollections(app, initialData);
     }

+ 16 - 9
packages/dev-server/load-testing/init-load-test.ts

@@ -12,7 +12,12 @@ import { initialData } from '../../core/mock-data/data-sources/initial-data';
 import { populateCustomers } from '../../core/mock-data/populate-customers';
 import { devConfig } from '../dev-config';
 
-import { getLoadTestConfig, getMysqlConnectionOptions, getProductCount, getProductCsvFilePath } from './load-test-config';
+import {
+    getLoadTestConfig,
+    getMysqlConnectionOptions,
+    getProductCount,
+    getProductCsvFilePath,
+} from './load-test-config';
 
 // tslint:disable:no-console
 
@@ -33,11 +38,13 @@ if (require.main === module) {
                             return generateProductsCsv(count);
                         }
                     })
-                    .then(() => populate(() => bootstrap(config),
-                        path.join(__dirname, '../../create/assets/initial-data.json'),
-                        csvFile,
-                        path.join(__dirname, './data-sources'),
-                    ))
+                    .then(() =>
+                        populate(
+                            () => bootstrap(config),
+                            path.join(__dirname, '../../create/assets/initial-data.json'),
+                            csvFile,
+                        ),
+                    )
                     .then(async app => {
                         console.log('populating customers...');
                         await populateCustomers(10, config as any, true);
@@ -90,7 +97,6 @@ function isDatabasePopulated(): Promise<boolean> {
             });
         });
     });
-
 }
 
 /**
@@ -110,7 +116,7 @@ function generateProductsCsv(productCount: number = 100): Promise<void> {
     stringifier.on('readable', () => {
         let row;
         // tslint:disable-next-line:no-conditional-assignment
-        while (row = stringifier.read()) {
+        while ((row = stringifier.read())) {
             data.push(row);
         }
     });
@@ -238,7 +244,8 @@ const parts = [
 ];
 function generateProductDescription(): string {
     const take = Math.ceil(Math.random() * 4);
-    return shuffle(parts).slice(0, take)
+    return shuffle(parts)
+        .slice(0, take)
         .join('. ');
 }