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

chore: ensure new-docs are up to date #5994

Merged
merged 2 commits into from Jun 11, 2020
Merged

Conversation

jackfranklin
Copy link
Collaborator

This adds a Travis check that if we re-generate the docs we get the
exact output (by checking if the Git tree is dirty).

We do the dirty check by using git status --porcelain, seeing how many
lines that outputs, and using that as the exit code (taking only the
first 255 lines to avoid invalid exit codes). --porcelain makes the
output be empty if the repo is not dirty in anyway which translates into
an exit code of 0.

This adds a Travis check that if we re-generate the docs we get the
exact output (by checking if the Git tree is dirty).

We do the dirty check by using `git status --porcelain`, seeing how many
lines that outputs, and using that as the exit code (taking only the
first 255 lines to avoid invalid exit codes). `--porcelain` makes the
output be empty if the repo is not dirty in anyway which translates into
an exit code of 0.
@@ -33,7 +33,8 @@
"update-protocol-d-ts": "node utils/protocol-types-generator update",
"compare-protocol-d-ts": "node utils/protocol-types-generator compare",
"test-install": "scripts/test-install.sh",
"generate-docs": "npm run tsc && api-extractor run --local --verbose && api-documenter markdown -i temp -o new-docs"
"generate-docs": "npm run tsc && api-extractor run --local --verbose && api-documenter markdown -i temp -o new-docs",
"ensure-new-docs-up-to-date": "npm run generate-docs && exit `git status --porcelain | head -255 | wc -l`"
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
"ensure-new-docs-up-to-date": "npm run generate-docs && exit `git status --porcelain | head -255 | wc -l`"
"ensure-new-docs-up-to-date": "npm run generate-docs && git diff-index --quiet HEAD"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This would be nicer, but doesn't error if there's an untracked file in the repo. e.g.:

// start with clean repo
touch foo.txt
git diff-index --quiet HEAD exits with 0 

Copy link
Member

@mathiasbynens mathiasbynens left a comment

Choose a reason for hiding this comment

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

git diff-index --quiet HEAD seems simpler, so let’s use that? LGTM otherwise 👍

@jackfranklin jackfranklin merged commit 91eb745 into master Jun 11, 2020
@jackfranklin jackfranklin deleted the ensure-new-docs-up-to-date branch June 11, 2020 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants