Skip to content

Commit 4c70561

Browse files
authored
Merge pull request #1005 from crazy-max/util-inputlist-comment
util: add commentNoInfix support to getInputList
2 parents 9e446b0 + 1ebb922 commit 4c70561

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

__tests__/util.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ describe('getInputList', () => {
8787
expect(res).toEqual(['foo=bar', 'bar=qux']);
8888
});
8989

90+
it('multiline with comment and no infix comment', async () => {
91+
setInput('labels', '# ignore this\nfoo=bar\nbar=qux#baz');
92+
const res = Util.getInputList('labels', {comment: '#', commentNoInfix: true});
93+
expect(res).toEqual(['foo=bar', 'bar=qux#baz']);
94+
});
95+
9096
it('different new lines and ignoring comma correctly', async () => {
9197
setInput('cache-from', 'user/app:cache\r\ntype=local,src=path/to/dir');
9298
const res = Util.getInputList('cache-from', {ignoreComma: true});

src/util.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {parse} from 'csv-parse/sync';
2424
export interface ListOpts {
2525
ignoreComma?: boolean;
2626
comment?: string;
27+
commentNoInfix?: boolean;
2728
quote?: string | boolean | Buffer | null;
2829
}
2930

@@ -42,6 +43,7 @@ export class Util {
4243
columns: false,
4344
relaxQuotes: true,
4445
comment: opts?.comment,
46+
comment_no_infix: opts?.commentNoInfix,
4547
relaxColumnCount: true,
4648
skipEmptyLines: true,
4749
quote: opts?.quote

0 commit comments

Comments
 (0)