Skip to content

Commit

Permalink
fix(repo): stop trimming whitespace of inputs (#524)
Browse files Browse the repository at this point in the history
* fix(repo): stop trimming whitespace of inputs

* unit test
  • Loading branch information
danadajian authored Jan 10, 2024
1 parent adc1a03 commit 95eec42
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47554,7 +47554,7 @@ limitations under the License.

const getActionInputs = (requiredInputs = []) => {
const yamlContents = (0,external_fs_.readFileSync)(`${__dirname}/action.yml`).toString();
const inputsFromFile = getInputsFromFile(yamlContents).reduce((acc, current) => (Object.assign(Object.assign({}, acc), { [current]: (0,core.getInput)(current, { required: requiredInputs.includes(current) }) })), {});
const inputsFromFile = getInputsFromFile(yamlContents).reduce((acc, current) => (Object.assign(Object.assign({}, acc), { [current]: (0,core.getInput)(current, { required: requiredInputs.includes(current), trimWhitespace: false }) })), {});
return (0,lodash.pickBy)(inputsFromFile);
};

Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/utils/get-action-inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const getActionInputs = (requiredInputs: string[] = []) => {
const inputsFromFile = getInputsFromFile(yamlContents).reduce(
(acc, current) => ({
...acc,
[current]: getInput(current, { required: requiredInputs.includes(current) })
[current]: getInput(current, { required: requiredInputs.includes(current), trimWhitespace: false })
}),
{}
);
Expand Down
6 changes: 3 additions & 3 deletions test/utils/get-action-inputs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ describe('getActionInputs', () => {
it('should call getInput with correct params and return expected inputs', () => {
const result = getActionInputs(requiredInputs);

expect(getInput).toHaveBeenCalledWith('input1', { required: true });
expect(getInput).toHaveBeenCalledWith('input2', { required: false });
expect(getInput).toHaveBeenCalledWith('input3', { required: false });
expect(getInput).toHaveBeenCalledWith('input1', { required: true, trimWhitespace: false });
expect(getInput).toHaveBeenCalledWith('input2', { required: false, trimWhitespace: false });
expect(getInput).toHaveBeenCalledWith('input3', { required: false, trimWhitespace: false });
expect(result).toEqual({
input1: 'input1',
input3: 'input3'
Expand Down

0 comments on commit 95eec42

Please sign in to comment.