Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use working directory of exec #16

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions src/eslint.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import path from 'node:path';

import { notice } from '@actions/core';
import { exec } from '@actions/exec';

Expand All @@ -22,11 +20,12 @@ export const runEslint = async (): Promise<void> => {

const eslintArgs = getEslintArgs();

const execOptions = [
inputs.useNpx ? 'eslint' : path.resolve(inputs.workingDirectory, 'node_modules/.bin/eslint'),
const execArgs = [
inputs.useNpx ? 'eslint' : 'node_modules/.bin/eslint',
...files,
...eslintArgs,
].filter(Boolean);
const execOptions = { cwd: inputs.workingDirectory };

await exec(inputs.useNpx ? 'npx' : 'node', execOptions);
await exec(inputs.useNpx ? 'npx' : 'node', execArgs, execOptions);
};
7 changes: 5 additions & 2 deletions src/get-files.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import path from 'node:path';

import { info } from '@actions/core';

import { FileNamesList } from './types';
Expand All @@ -18,9 +20,10 @@ const getFiles = async (): Promise<FileNamesList> => {
printItems('Files changed.', changedFiles);

const files = await ignoreFiles(changedFiles);
printItems('Files for linting', files);
const relativeFiles = files.map((file) => path.relative(inputs.workingDirectory, file));
printItems('Files for linting', relativeFiles);

return files;
return relativeFiles;
};

export default getFiles;