From d7b0c73d094c09ee8d03c58fcfb0915223f85361 Mon Sep 17 00:00:00 2001 From: Sebastian Szewczyk Date: Mon, 25 Sep 2023 16:00:44 +0200 Subject: [PATCH] Using absolute path in detectFunction --- .github/actions/javascript/authorChecklist/index.js | 8 ++++---- .../javascript/authorChecklist/newComponentCategory.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/actions/javascript/authorChecklist/index.js b/.github/actions/javascript/authorChecklist/index.js index c33b58edddd7..55ea0e72391e 100644 --- a/.github/actions/javascript/authorChecklist/index.js +++ b/.github/actions/javascript/authorChecklist/index.js @@ -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 = { diff --git a/.github/actions/javascript/authorChecklist/newComponentCategory.js b/.github/actions/javascript/authorChecklist/newComponentCategory.js index 58aef738e37e..79b05d1baee3 100644 --- a/.github/actions/javascript/authorChecklist/newComponentCategory.js +++ b/.github/actions/javascript/authorChecklist/newComponentCategory.js @@ -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 = {