Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not attempt to read directory as file #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion analysisTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export class AnalysisTool {
(filename: string, data: string) => this.checkFileForScriptingLanguage(filename, data),
(filename: string, data: string) => this.checkFileForComponent(filename, data),
];
if (currentPath.substr(-3) === '.js' || this.fileHasTsExtension(currentPath) || currentPath.substr(-5) === '.html' || currentPath.substr(-5) === '.json') {
if ((currentPath.substr(-3) === '.js' || this.fileHasTsExtension(currentPath) || currentPath.substr(-5) === '.html' || currentPath.substr(-5) === '.json') && fs.lstatSync(currentPath).isFile()) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like you would want this isFile() at a higher level so that it would apply whether the directory had .json or .html in it, basically it shouldn't check any of these file extensions unless it's dealing with a file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sounds like an optimization, my solution worked for me allowing me to use the tool, so I decided to share. If you believe there's a better solution - please create a new PR, I don't use this tool anymore and didn't find it to be particularly helpful. Cheers!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Splaktar I wonder if you think it's ok to merge?

this.analysisDetails.relevantFilesOrFolderCount++;
for (let test of tests) {
try {
Expand Down