diff --git a/.github/actions/javascript/authorChecklist/index.js b/.github/actions/javascript/authorChecklist/index.js index 64f166c9709e..92acecf09395 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 path = __nccwpck_require__(5622); const CONST = __nccwpck_require__(4097); const items = [ @@ -248,16 +249,23 @@ function detectReactComponent(code) { }; function readFile(filename) { - const path = `./${filename}`; + const filePath = `./${filename}`; try { - return fs.readFileSync(path, 'utf-8'); + console.log('reading', filePath, fs.existsSync('./package.json')); + return fs.readFileSync(filePath, 'utf-8'); } catch (error) { - console.error(`Error reading ${path}`, error); + console.error(`Error reading ${filePath}`, error); } } function detectFunction(changedFiles) { console.log('detectFunction', process.cwd()); + + fs.readdirSync(process.cwd()).forEach(file => { + console.log(file); + }); + + const filteredFiles = _.filter((changedFiles), ({ filename }) => filename.endsWith('.js') || filename.endsWith('.jsx') || filename.endsWith('.ts') || filename.endsWith('.tsx')); return _.some(filteredFiles, ({ filename }) => detectReactComponent(readFile(filename))); } diff --git a/.github/actions/javascript/authorChecklist/newComponentCategory.js b/.github/actions/javascript/authorChecklist/newComponentCategory.js index fe7c2e7597e3..4be84a9515a0 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 path = require('path'); const CONST = require('../../../libs/CONST'); const items = [ @@ -48,16 +49,23 @@ function detectReactComponent(code) { }; function readFile(filename) { - const path = `./${filename}`; + const filePath = `./${filename}`; try { - return fs.readFileSync(path, 'utf-8'); + console.log('reading', filePath, fs.existsSync('./package.json')); + return fs.readFileSync(filePath, 'utf-8'); } catch (error) { - console.error(`Error reading ${path}`, error); + console.error(`Error reading ${filePath}`, error); } } function detectFunction(changedFiles) { console.log('detectFunction', process.cwd()); + + fs.readdirSync(process.cwd()).forEach(file => { + console.log(file); + }); + + const filteredFiles = _.filter((changedFiles), ({ filename }) => filename.endsWith('.js') || filename.endsWith('.jsx') || filename.endsWith('.ts') || filename.endsWith('.tsx')); return _.some(filteredFiles, ({ filename }) => detectReactComponent(readFile(filename))); }