Skip to content

Commit

Permalink
Using absolute path in detectFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
sebryu committed Sep 25, 2023
1 parent c2136a6 commit d7b0c73
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions .github/actions/javascript/authorChecklist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,14 @@ function detectReactComponent(code) {
return isReactComponent;
};

function relativePath(filename) {
return `../../../../${filename}`;
function absolutePath(filename) {
return `${process.cwd()}/${filename}`;
}

function detectFunction(changedFiles) {
console.log('detectFunction', changedFiles);
console.log('detectFunction', process.cwd());
const filteredFiles = _.filter((changedFiles), ({ filename }) => filename.endsWith('.js') || filename.endsWith('.jsx') || filename.endsWith('.ts') || filename.endsWith('.tsx'));
return _.some(filteredFiles, ({ filename }) => detectReactComponent(fs.readFileSync(relativePath(filename), 'utf-8')));
return _.some(filteredFiles, ({ filename }) => detectReactComponent(fs.readFileSync(absolutePath(filename), 'utf-8')));
}

module.exports = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ function detectReactComponent(code) {
return isReactComponent;
};

function relativePath(filename) {
return `../../../../${filename}`;
function absolutePath(filename) {
return `${process.cwd()}/${filename}`;
}

function detectFunction(changedFiles) {
console.log('detectFunction', changedFiles);
console.log('detectFunction', process.cwd());
const filteredFiles = _.filter((changedFiles), ({ filename }) => filename.endsWith('.js') || filename.endsWith('.jsx') || filename.endsWith('.ts') || filename.endsWith('.tsx'));
return _.some(filteredFiles, ({ filename }) => detectReactComponent(fs.readFileSync(relativePath(filename), 'utf-8')));
return _.some(filteredFiles, ({ filename }) => detectReactComponent(fs.readFileSync(absolutePath(filename), 'utf-8')));
}

module.exports = {
Expand Down

0 comments on commit d7b0c73

Please sign in to comment.