mirror of
https://github.com/docker/bake-action.git
synced 2026-01-22 20:32:21 +01:00
Fix csv-parse implementation since major update
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -1,10 +1,13 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
clearMocks: true,
|
clearMocks: true,
|
||||||
moduleFileExtensions: ['js', 'ts'],
|
moduleFileExtensions: ['js', 'ts'],
|
||||||
setupFiles: ["dotenv/config"],
|
setupFiles: ['dotenv/config'],
|
||||||
testMatch: ['**/*.test.ts'],
|
testMatch: ['**/*.test.ts'],
|
||||||
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 fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
@@ -96,19 +96,21 @@ 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,
|
||||||
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());
|
||||||
|
|||||||
Reference in New Issue
Block a user