From 99e431eee2afb98184af17582221bedac4cf41ae Mon Sep 17 00:00:00 2001 From: Sebastian Szewczyk Date: Mon, 25 Sep 2023 16:06:49 +0200 Subject: [PATCH] Fixed path in detectFunction --- .github/actions/javascript/authorChecklist/index.js | 7 ++++--- .../javascript/authorChecklist/newComponentCategory.js | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/actions/javascript/authorChecklist/index.js b/.github/actions/javascript/authorChecklist/index.js index 55ea0e72391e..b0521eae1ee7 100644 --- a/.github/actions/javascript/authorChecklist/index.js +++ b/.github/actions/javascript/authorChecklist/index.js @@ -202,6 +202,7 @@ const { parse } = __nccwpck_require__(639); const traverse = __nccwpck_require__(5008).default; const _ = __nccwpck_require__(2947); const fs = __nccwpck_require__(5747); +const CONST = __nccwpck_require__(4097); const items = [ "I verified that similar component doesn't exist in the codebase", @@ -243,14 +244,14 @@ function detectReactComponent(code) { return isReactComponent; }; -function absolutePath(filename) { - return `${process.cwd()}/${filename}`; +function relativePath(filename) { + return filename.replace(`${CONST.APP_NAME}/`, ''); } function 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(absolutePath(filename), 'utf-8'))); + return _.some(filteredFiles, ({ filename }) => detectReactComponent(fs.readFileSync(relativePath(filename), 'utf-8'))); } module.exports = { diff --git a/.github/actions/javascript/authorChecklist/newComponentCategory.js b/.github/actions/javascript/authorChecklist/newComponentCategory.js index 79b05d1baee3..d81970f360ee 100644 --- a/.github/actions/javascript/authorChecklist/newComponentCategory.js +++ b/.github/actions/javascript/authorChecklist/newComponentCategory.js @@ -2,6 +2,7 @@ const { parse } = require('@babel/parser'); const traverse = require('@babel/traverse').default; const _ = require('underscore'); const fs = require('fs'); +const CONST = require('../../../libs/CONST'); const items = [ "I verified that similar component doesn't exist in the codebase", @@ -43,14 +44,14 @@ function detectReactComponent(code) { return isReactComponent; }; -function absolutePath(filename) { - return `${process.cwd()}/${filename}`; +function relativePath(filename) { + return filename.replace(`${CONST.APP_NAME}/`, ''); } function 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(absolutePath(filename), 'utf-8'))); + return _.some(filteredFiles, ({ filename }) => detectReactComponent(fs.readFileSync(relativePath(filename), 'utf-8'))); } module.exports = {