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

Conversation

Maxim-Mazurok
Copy link

Fixes #30

@Maxim-Mazurok Maxim-Mazurok changed the title Update analysisTool.ts Do not attempt to read directory as file Feb 10, 2022
@@ -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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Attempts to read directory as file
2 participants