Skip to content

Commit

Permalink
Debugging read files problems
Browse files Browse the repository at this point in the history
  • Loading branch information
sebryu committed Sep 25, 2023
1 parent f3f5910 commit 7bd1e44
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
14 changes: 11 additions & 3 deletions .github/actions/javascript/authorChecklist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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)));
}
Expand Down
14 changes: 11 additions & 3 deletions .github/actions/javascript/authorChecklist/newComponentCategory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Check failure on line 5 in .github/actions/javascript/authorChecklist/newComponentCategory.js

View workflow job for this annotation

GitHub Actions / lint

'path' is assigned a value but never used
const CONST = require('../../../libs/CONST');

Check failure on line 6 in .github/actions/javascript/authorChecklist/newComponentCategory.js

View workflow job for this annotation

GitHub Actions / lint

'CONST' is assigned a value but never used

const items = [
Expand Down Expand Up @@ -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)));
}
Expand Down

0 comments on commit 7bd1e44

Please sign in to comment.