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

build(opentrons): add onchange watch to make format command #4804

Merged
merged 2 commits into from
Jan 21, 2020

Conversation

iansolano
Copy link
Contributor

@iansolano iansolano commented Jan 17, 2020

Add onchange lib to conditionally watch files using make format watch=true command and invoke
prettier on changed file

overview

Added onchange library recommended by prettier https://github.com/prettier/prettier/blob/master/docs/watching-files.md.

Initially tried to implement using watchman but proved to be quite difficult / could potentially require additional implied dependencies. Onchange is nice because now it requires no additional setups for engineers to begin watching for changes and running prettier.

Curious about watchman issues / have other ideas? These were my findings:

review requests

Open to different implementation suggestions and there are way to make this work with watchman but the ones I could think of seem unnecessarily burdensome to do a simple task like this.

Add onchange lib to conditionally watch files using make format watch=true command and invoke
prettier
@codecov
Copy link

codecov bot commented Jan 17, 2020

Codecov Report

Merging #4804 into edge will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             edge    #4804   +/-   ##
=======================================
  Coverage   57.91%   57.91%           
=======================================
  Files         956      956           
  Lines       26235    26235           
=======================================
  Hits        15194    15194           
  Misses      11041    11041

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6e28b2b...7d44ae5. Read the comment docs.

Copy link
Contributor

@mcous mcous left a comment

Choose a reason for hiding this comment

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

automatic formatting ftw 👔

@@ -82,6 +82,7 @@
"madge": "^3.6.0",
"mime": "^2.4.4",
"mini-css-extract-plugin": "^0.8.0",
"onchange": "^6.1.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for humoring me and trying out watchman. I foolishly forgot how much it sucks. Looks like onchange is a quality package (and uses chokidar under the hood) so 👍

Copy link
Contributor Author

@iansolano iansolano Jan 17, 2020

Choose a reason for hiding this comment

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

Np. Yeah, watchman deep smh 💀🌚

Makefile Outdated
@@ -114,7 +114,13 @@ lint: lint-py lint-js lint-json lint-css check-js circular-dependencies-js

.PHONY: format
format:
prettier --ignore-path .eslintignore $(if $(CI),--check,--write) ".*.@(js|yml)" "**/*.@(js|json|md|yml)"
ifeq ($(watch),true)
onchange ".*.@(js|yml)" "**/*.@(js|json|md|yml)" -- \
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like it might be good to throw these formatted file patterns into an internal Makefile variable

@iansolano iansolano merged commit af819a1 into edge Jan 21, 2020
@iansolano iansolano deleted the ot_add_format_watch branch January 21, 2020 17:03
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.

None yet

2 participants