Skip to content

Commit

Permalink
fix: Don't warn for header row in Excel file when importing master items
Browse files Browse the repository at this point in the history
Fixes #82
  • Loading branch information
Göran Sander committed Oct 13, 2022
1 parent 10136c8 commit 2ef9d0e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/ctrl-q.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const { deleteMasterMeasure } = require('./lib/deletemeasure');

const { getBookmark } = require('./lib/getbookmark');

const { importMasterItemFromFile } = require('./lib/importexcel');
const { importMasterItemFromFile } = require('./lib/import-masteritem-excel');

const { scrambleField } = require('./lib/scramblefield');
const { getScript } = require('./lib/getscript');
Expand Down
13 changes: 10 additions & 3 deletions src/lib/importexcel.js → src/lib/import-masteritem-excel.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ const importMasterItemFromExcel = async (options) => {
// Loop through rows in Excel file, extracting data for rows flagged as master items
let importCount = 0;
if (sheet && sheet.data.length > 0) {
let rowCount = 0;

// Loop through all rows
// eslint-disable-next-line no-restricted-syntax
for (const row of sheet.data) {
Expand Down Expand Up @@ -301,10 +303,15 @@ const importMasterItemFromExcel = async (options) => {
}
}
} else {
logger.warn(
`Found an unknown master item type: "${row[colPosMasterItemType]}". Ignoring this line in the imported file.`
);
// Don't warn if it's the first line/header in the Excel file
// eslint-disable-next-line no-lonely-if
if (rowCount !== 0) {
logger.warn(
`Found an unknown master item type: "${row[colPosMasterItemType]}". Ignoring this line in the imported file.`
);
}
}
rowCount += 1;
}
}

Expand Down

0 comments on commit 2ef9d0e

Please sign in to comment.