Skip to content

Fixed error in Profiling Plugin, if given folder path doesn't exist. #8565

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

Merged
merged 3 commits into from
Dec 29, 2018

Conversation

NaviMarella
Copy link
Contributor

This is a fix for the below issue. Profiling plugin will create a folder based on the output path, if it doesn't exists.

#8503

What kind of change does this PR introduce?

bugfix

Did you add tests for your changes?

Yes, i have added a test for checking if folder is getting created in the provided path.

Does this PR introduce a breaking change?

No

What needs to be documented once your changes are merged?

No documentation needed.

@webpack-bot
Copy link
Contributor

For maintainers only:

  • This need to be documented (issue in webpack/webpack.js.org will be filed when merged)

@NaviMarella NaviMarella changed the title Fixed Profiling Output path for creating a folder, if it doesn't exists. Fixed error in Profiling Plugin, it given folder path doesn't exist. Dec 27, 2018
@NaviMarella NaviMarella changed the title Fixed error in Profiling Plugin, it given folder path doesn't exist. Fixed error in Profiling Plugin, if given folder path doesn't exist. Dec 27, 2018
@webpack-bot
Copy link
Contributor

Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon.

const trace = new Tracer({
noStream: true
});
const profiler = new Profiler(inspector);
if (outputPath.match(/\/|\\/)) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (outputPath.match(/\/|\\/)) {
if (/\/|\\/.test(outputPath)) {

But I think this isn't needed as it's always true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This results to false, when they don't send any outputPath. It defaults to "events.json" as the outputpath.

const trace = new Tracer({
noStream: true
});
const profiler = new Profiler(inspector);
if (outputPath.match(/\/|\\/)) {
const dir = path.dirname(outputPath);
compiler.outputFileSystem.mkdirp(dir);
Copy link
Member

Choose a reason for hiding this comment

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

mkdirp has a callback afaik

Copy link
Member

Choose a reason for hiding this comment

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

Here it would becomes a bit tricky to get the async correctly.

I think it's fine to use the sync version here. You should not use the outputFileSystem here, but the real fs. Best import mkdirp and call mkdirp.sync.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made changes as requested. Thanks @sokra for your suggestions.

Would like to learn even more during this process and contribute to Webpack.

@webpack-bot
Copy link
Contributor

@NaviMarella Thanks for your update.

I labeled the Pull Request so reviewers will review it again.

@sokra Please review the new changes.

@sokra sokra merged commit 510abf7 into webpack:master Dec 29, 2018
@sokra
Copy link
Member

sokra commented Dec 29, 2018

Thanks

hulkish pushed a commit to hulkish/webpack that referenced this pull request Dec 29, 2018
Fixed error in Profiling Plugin, if given folder path doesn't exist.
@NaviMarella NaviMarella deleted the ProfilingPlugin_8503 branch December 29, 2018 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants