Skip to content

Commit

Permalink
fix(path): use $GITHUB_PATH
Browse files Browse the repository at this point in the history
  • Loading branch information
JPBM135 committed Jan 18, 2024
1 parent 4a4ca3c commit ba52057
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('Self-Hosted Actions Polyfill', () => {
await main();

expect(core.setFailed).not.toHaveBeenCalled();
expect(exec.exec).toHaveBeenCalledTimes(4);
expect(exec.exec).toHaveBeenCalledTimes(5);

expect(exec.exec).toHaveBeenCalledWith('sudo', ['apt-get', 'update', '-y'], expect.anything());

Expand All @@ -53,9 +53,13 @@ describe('Self-Hosted Actions Polyfill', () => {

expect(exec.exec).toHaveBeenCalledWith('/bin/bash', ['-c', POLYFILLS.yarn?.command], expect.anything());

expect(exec.exec).toHaveBeenLastCalledWith('sudo', ['apt-get', 'autoremove', '-y'], expect.anything());
expect(exec.exec).toHaveBeenCalledWith(
'/bin/bash',
['-c', `echo "${POLYFILLS.yarn.path}" >> $GITHUB_PATH`],
expect.anything(),
);

expect(core.addPath).toHaveBeenCalledWith(POLYFILLS.yarn.path!);
expect(exec.exec).toHaveBeenLastCalledWith('sudo', ['apt-get', 'autoremove', '-y'], expect.anything());
});

it('should throw an error if the platform is not supported', async () => {
Expand Down
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ export async function main() {
});

if (polyfillOptions.path) {
core.addPath(polyfillOptions.path);
const escapedPath = polyfillOptions.path.replaceAll('"', '\\"');

await exec.exec('/bin/bash', ['-c', `echo "${escapedPath}" >> $GITHUB_PATH`], {
...createStreams(),
});

core.info(`Added ${polyfill} polyfill to PATH.`);
}

Expand Down

0 comments on commit ba52057

Please sign in to comment.