diff --git a/jest.config.ts b/jest.config.ts index ebf22a5..7ff4e46 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -1,10 +1,13 @@ module.exports = { clearMocks: true, moduleFileExtensions: ['js', 'ts'], - setupFiles: ["dotenv/config"], + setupFiles: ['dotenv/config'], testMatch: ['**/*.test.ts'], transform: { '^.+\\.ts$': 'ts-jest' }, + moduleNameMapper: { + '^csv-parse/sync': '/node_modules/csv-parse/dist/cjs/sync.cjs' + }, verbose: true -} +}; diff --git a/src/context.ts b/src/context.ts index e145e54..24dc781 100644 --- a/src/context.ts +++ b/src/context.ts @@ -1,4 +1,4 @@ -import csvparse from 'csv-parse/lib/sync'; +import {parse} from 'csv-parse/sync'; import * as fs from 'fs'; import * as os from 'os'; import * as path from 'path'; @@ -96,19 +96,21 @@ export function getInputList(name: string, ignoreComma?: boolean): string[] { return res; } - for (const output of csvparse(items, { + const records = parse(items, { columns: false, relaxColumnCount: true, - skipLinesWithEmptyValues: true - }) as Array) { - if (output.length == 1) { - res.push(output[0]); + skipEmptyLines: true + }); + + for (const record of records as Array) { + if (record.length == 1) { + res.push(record[0]); continue; } else if (!ignoreComma) { - res.push(...output); + res.push(...record); continue; } - res.push(output.join(',')); + res.push(record.join(',')); } return res.filter(item => item).map(pat => pat.trim());