Fix csv-parse implementation since major update
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
2a96a96c9c
commit
b7ad32e4f5
|
@ -6,5 +6,8 @@ module.exports = {
|
||||||
transform: {
|
transform: {
|
||||||
'^.+\\.ts$': 'ts-jest'
|
'^.+\\.ts$': 'ts-jest'
|
||||||
},
|
},
|
||||||
|
moduleNameMapper: {
|
||||||
|
'^csv-parse/sync': '<rootDir>/node_modules/csv-parse/dist/cjs/sync.cjs'
|
||||||
|
},
|
||||||
verbose: true
|
verbose: true
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import csvparse from 'csv-parse/lib/sync';
|
import {parse} from 'csv-parse/sync';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import {issueCommand} from '@actions/core/lib/command';
|
import {issueCommand} from '@actions/core/lib/command';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
@ -46,21 +46,23 @@ export function getInputList(name: string, ignoreComma?: boolean): string[] {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const output of csvparse(items, {
|
const records = parse(items, {
|
||||||
columns: false,
|
columns: false,
|
||||||
relax: true,
|
relaxQuotes: true,
|
||||||
comment: '#',
|
comment: '#',
|
||||||
relaxColumnCount: true,
|
relaxColumnCount: true,
|
||||||
skipLinesWithEmptyValues: true
|
skipEmptyLines: true
|
||||||
}) as Array<string[]>) {
|
});
|
||||||
if (output.length == 1) {
|
|
||||||
res.push(output[0]);
|
for (const record of records as Array<string[]>) {
|
||||||
|
if (record.length == 1) {
|
||||||
|
res.push(record[0]);
|
||||||
continue;
|
continue;
|
||||||
} else if (!ignoreComma) {
|
} else if (!ignoreComma) {
|
||||||
res.push(...output);
|
res.push(...record);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
res.push(output.join(','));
|
res.push(record.join(','));
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.filter(item => item).map(pat => pat.trim());
|
return res.filter(item => item).map(pat => pat.trim());
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
import {parse} from 'csv-parse/sync';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import csvparse from 'csv-parse/lib/sync';
|
|
||||||
|
|
||||||
export interface Flavor {
|
export interface Flavor {
|
||||||
latest: string;
|
latest: string;
|
||||||
|
@ -19,9 +19,9 @@ export function Transform(inputs: string[]): Flavor {
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const input of inputs) {
|
for (const input of inputs) {
|
||||||
const fields = csvparse(input, {
|
const fields = parse(input, {
|
||||||
relaxColumnCount: true,
|
relaxColumnCount: true,
|
||||||
skipLinesWithEmptyValues: true
|
skipEmptyLines: true
|
||||||
})[0];
|
})[0];
|
||||||
let onlatestfor = '';
|
let onlatestfor = '';
|
||||||
for (const field of fields) {
|
for (const field of fields) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import csvparse from 'csv-parse/lib/sync';
|
import {parse} from 'csv-parse/sync';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
|
||||||
export enum Type {
|
export enum Type {
|
||||||
|
@ -86,9 +86,9 @@ export function Transform(inputs: string[]): Tag[] {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Parse(s: string): Tag {
|
export function Parse(s: string): Tag {
|
||||||
const fields = csvparse(s, {
|
const fields = parse(s, {
|
||||||
relaxColumnCount: true,
|
relaxColumnCount: true,
|
||||||
skipLinesWithEmptyValues: true
|
skipEmptyLines: true
|
||||||
})[0];
|
})[0];
|
||||||
|
|
||||||
const tag = new Tag();
|
const tag = new Tag();
|
||||||
|
|
Loading…
Reference in New Issue