Merge pull request #1099 from crazy-max/inputlist-trim-opt
Some checks failed
undock-releases-json / generate (push) Has been cancelled
undock-releases-json / open-pr (push) Has been cancelled
regclient-releases-json / generate (push) Has been cancelled
regclient-releases-json / open-pr (push) Has been cancelled
docker-releases-json / generate (push) Has been cancelled
docker-releases-json / open-pr (push) Has been cancelled
cosign-releases-json / generate (push) Has been cancelled
cosign-releases-json / open-pr (push) Has been cancelled
compose-releases-json / generate (push) Has been cancelled
compose-releases-json / open-pr (push) Has been cancelled
compose-lab-releases-json / generate (push) Has been cancelled
compose-lab-releases-json / open-pr (push) Has been cancelled
buildx-releases-json / generate (push) Has been cancelled
buildx-releases-json / open-pr (push) Has been cancelled
buildx-lab-releases-json / generate (push) Has been cancelled
buildx-lab-releases-json / open-pr (push) Has been cancelled
build / build (20) (push) Has been cancelled
build / build (24) (push) Has been cancelled
codeql / analyze (push) Has been cancelled
test / test (20, ubuntu-24.04-arm) (push) Has been cancelled
test / test (20, ubuntu-latest) (push) Has been cancelled
test / test (24, ubuntu-24.04-arm) (push) Has been cancelled
test / test (24, ubuntu-latest) (push) Has been cancelled
test / prepare-itg (push) Has been cancelled
test / test-itg (push) Has been cancelled
update-deps / update (buildkit) (push) Has been cancelled
update-deps / update (buildx) (push) Has been cancelled
update-deps / update (compose) (push) Has been cancelled
update-deps / update (cosign) (push) Has been cancelled
update-deps / update (docker) (push) Has been cancelled
update-deps / update (regctl) (push) Has been cancelled
update-deps / update (undock) (push) Has been cancelled
validate / prepare (push) Has been cancelled
validate / validate (push) Has been cancelled
zizmor / run (push) Has been cancelled
publish / publish (push) Has been cancelled
Some checks failed
undock-releases-json / generate (push) Has been cancelled
undock-releases-json / open-pr (push) Has been cancelled
regclient-releases-json / generate (push) Has been cancelled
regclient-releases-json / open-pr (push) Has been cancelled
docker-releases-json / generate (push) Has been cancelled
docker-releases-json / open-pr (push) Has been cancelled
cosign-releases-json / generate (push) Has been cancelled
cosign-releases-json / open-pr (push) Has been cancelled
compose-releases-json / generate (push) Has been cancelled
compose-releases-json / open-pr (push) Has been cancelled
compose-lab-releases-json / generate (push) Has been cancelled
compose-lab-releases-json / open-pr (push) Has been cancelled
buildx-releases-json / generate (push) Has been cancelled
buildx-releases-json / open-pr (push) Has been cancelled
buildx-lab-releases-json / generate (push) Has been cancelled
buildx-lab-releases-json / open-pr (push) Has been cancelled
build / build (20) (push) Has been cancelled
build / build (24) (push) Has been cancelled
codeql / analyze (push) Has been cancelled
test / test (20, ubuntu-24.04-arm) (push) Has been cancelled
test / test (20, ubuntu-latest) (push) Has been cancelled
test / test (24, ubuntu-24.04-arm) (push) Has been cancelled
test / test (24, ubuntu-latest) (push) Has been cancelled
test / prepare-itg (push) Has been cancelled
test / test-itg (push) Has been cancelled
update-deps / update (buildkit) (push) Has been cancelled
update-deps / update (buildx) (push) Has been cancelled
update-deps / update (compose) (push) Has been cancelled
update-deps / update (cosign) (push) Has been cancelled
update-deps / update (docker) (push) Has been cancelled
update-deps / update (regctl) (push) Has been cancelled
update-deps / update (undock) (push) Has been cancelled
validate / prepare (push) Has been cancelled
validate / validate (push) Has been cancelled
zizmor / run (push) Has been cancelled
publish / publish (push) Has been cancelled
util: add opt-in whitespace preservation for multiline inputs
This commit is contained in:
@@ -157,6 +157,28 @@ ccc`
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('preserves trailing new lines when trimming is disabled', async () => {
|
||||||
|
setInput(
|
||||||
|
'secrets',
|
||||||
|
`"PRIVATE_SSH_KEY=TESTESTTESTESTTESTESTTESTEST
|
||||||
|
TESTESTTESTESTTESTESTTESTEST
|
||||||
|
TESTESTTESTESTTESTESTTESTEST
|
||||||
|
|
||||||
|
|
||||||
|
"
|
||||||
|
`
|
||||||
|
);
|
||||||
|
const res = Util.getInputList('secrets', {ignoreComma: true, trimWhitespace: false});
|
||||||
|
expect(res).toEqual([
|
||||||
|
`PRIVATE_SSH_KEY=TESTESTTESTESTTESTESTTESTEST
|
||||||
|
TESTESTTESTESTTESTESTTESTEST
|
||||||
|
TESTESTTESTESTTESTESTTESTEST
|
||||||
|
|
||||||
|
|
||||||
|
`
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
it('multiline values without quotes', async () => {
|
it('multiline values without quotes', async () => {
|
||||||
setInput(
|
setInput(
|
||||||
'secrets',
|
'secrets',
|
||||||
|
|||||||
@@ -27,11 +27,12 @@ export interface ListOpts {
|
|||||||
comment?: string;
|
comment?: string;
|
||||||
commentNoInfix?: boolean;
|
commentNoInfix?: boolean;
|
||||||
quote?: string | boolean | Buffer | null;
|
quote?: string | boolean | Buffer | null;
|
||||||
|
trimWhitespace?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Util {
|
export class Util {
|
||||||
public static getInputList(name: string, opts?: ListOpts): string[] {
|
public static getInputList(name: string, opts?: ListOpts): string[] {
|
||||||
return this.getList(core.getInput(name), opts);
|
return this.getList(core.getInput(name, {trimWhitespace: opts?.trimWhitespace !== false}), opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static getList(input: string, opts?: ListOpts): string[] {
|
public static getList(input: string, opts?: ListOpts): string[] {
|
||||||
@@ -64,7 +65,7 @@ export class Util {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.filter(item => item).map(pat => pat.trim());
|
return res.filter(item => item).map(item => (opts?.trimWhitespace === false ? item : item.trim()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static getInputNumber(name: string): number | undefined {
|
public static getInputNumber(name: string): number | undefined {
|
||||||
|
|||||||
Reference in New Issue
Block a user