Răsfoiți Sursa

Зависимость NOMINATION заменена на FILE_NAME

Ryan Wright 4 luni în urmă
părinte
comite
a8490b673e
3 a modificat fișierele cu 6 adăugiri și 7 ștergeri
  1. 2 2
      package-lock.json
  2. 1 1
      package.json
  3. 3 4
      script.js

+ 2 - 2
package-lock.json

@@ -1,12 +1,12 @@
 {
   "name": "jen-work-benefit-letters",
-  "version": "1.0.0",
+  "version": "1.1.0",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
     "": {
       "name": "jen-work-benefit-letters",
-      "version": "1.0.0",
+      "version": "1.1.0",
       "license": "ISC",
       "dependencies": {
         "csv-reader": "^1.0.12",

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "jen-work-benefit-letters",
-  "version": "1.0.0",
+  "version": "1.1.0",
   "description": "",
   "main": "index.js",
   "scripts": {

+ 3 - 4
script.js

@@ -39,10 +39,9 @@ const pdfStream = new Transform({
     const buffer = doc.getZip().generate({
       type: "nodebuffer",
     });
-    const fileName = `${row.NOMINATION.replace(
-      "Изобразительное искусство",
-      "ИЗО"
-    ).replace("Декоративно-прикладное искусство", "ДПИ")} ${row.NAME}`;
+    const fileName = row.FILE_NAME;
+    if (!fileName)
+      throw new Error("В таблице обязательно должно быть поле FILE_NAME");
 
     fs.writeFileSync(
       path.resolve(__dirname, "docx", `${fileName}.docx`),