← 输入框|github.com|刷新
Skip to content

Implement configuration through a config file - #23

Merged
jsumners merged 14 commits into
fastify:mainfrom
MSE99:feat-more-opts#18
Jul 2, 2021
Merged

jsumners merged 14 commits into
fastify:mainfrom
MSE99:feat-more-opts#18

Conversation

@MSE99

@MSE99 MSE99 commented Jul 1, 2021 •

Copy link
Copy Markdown
Contributor

Checklist

Description

This PR allows the users to create a .pre-commit.json the contents of this file will be used to override config defined in pre-commit property inside package.json effectively implementing one feature mentioned in #18.

Note: This PR also adds .nyc_output to .gitignore.

@zekth

zekth commented Jul 1, 2021

Copy link
Copy Markdown
Member

Shouldn't we put the naming as .pre-commit.json instead? To be considered as a 'dotfile' which is more convinient for configuration files.

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you please:

  • update the README
  • remove package-lock.json and add it to .gitignore

Comment thread index.js Outdated
try {
const raw = fs.readFileSync(path.join(this.root, '.pre-commit.json'), 'utf-8').toString()
preCommitConfig = JSON.parse(raw)
} catch (err) {}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this should differentiate between file not found and other permission errors, e.g. if the file exists and we cannot access it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do you mean that we should log the error object to the console?, should we exit the process with an error code too or should we ignore the error and continue?.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

to me we should warn the user in a case of a present but not readable file; if there is no file we load the default configuration

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm fine with either option. Silently ignoring it is not good.

Comment thread test.js Outdated
t.test('overrides the `pre-commit` config property in package.json with the config inside pre-commit.json if it exists', function (t) {
t.plan(1)

const fs = require('fs')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you please use proxyquire instead?

@MSE99
MSE99 requested review from mcollina and zekth July 2, 2021 11:49
@jsumners
jsumners changed the base branch from main to next July 2, 2021 11:58
@jsumners

jsumners commented Jul 2, 2021

Copy link
Copy Markdown
Member

Looking good. Please rebase on the next branch.

climba03003 and others added 14 commits July 2, 2021 14:28
* ci: remove old ci

* ci: use github ci
…ify#11)

Bumps [fastify/github-action-merge-dependabot](https://github.com/fastify/github-action-merge-dependabot) from 1.2.0 to 2.0.0.
- [Release notes](https://github.com/fastify/github-action-merge-dependabot/releases)
- [Commits](fastify/github-action-merge-dependabot@v1.2.0...v2.0.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 2.1.4 to 2.1.5.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](actions/setup-node@v2.1.4...v2.1.5)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…ify#20)

Bumps [fastify/github-action-merge-dependabot](https://github.com/fastify/github-action-merge-dependabot) from 2.0.0 to 2.1.0.
- [Release notes](https://github.com/fastify/github-action-merge-dependabot/releases)
- [Commits](fastify/github-action-merge-dependabot@v2.0.0...v2.1.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…ify#21)

Bumps [fastify/github-action-merge-dependabot](https://github.com/fastify/github-action-merge-dependabot) from 2.1.0 to 2.1.1.
- [Release notes](https://github.com/fastify/github-action-merge-dependabot/releases)
- [Commits](fastify/github-action-merge-dependabot@v2.1.0...v2.1.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
(SUMMARY)

* Implements loading of optional config file `pre-commit.json` inside the root
  directory of the git repository.

* The contents of `pre-commit.json` will override whatever the user has specified
  in the `pre-commit` or `precommit` property inside package.json, everything
  else will behave the same.
@MSE99
MSE99 force-pushed the feat-more-opts#18 branch from c6628db to 5e5da89 Compare July 2, 2021 12:30

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@jsumners

jsumners commented Jul 2, 2021

Copy link
Copy Markdown
Member

@MSE99 how did you perform the rebase? It should have looked something like:

$ git remote add upstream https://github.com/fastify/pre-commit.git
$ git fetch upstream next
$ git rebase upstream/next

In that case, we shouldn't be seeing all of the prior commits to the next branch included in this pull request.

@MSE99

MSE99 commented Jul 2, 2021

Copy link
Copy Markdown
Contributor Author

@jsumners I did it the same way except that i had my main branch set up to track upstream/main instead of origin/main.

@jsumners

jsumners commented Jul 2, 2021

Copy link
Copy Markdown
Member

We need to target the next branch. Not the main branch.

@jsumners

jsumners commented Jul 2, 2021

Copy link
Copy Markdown
Member

Nevermind. I see that we have messed up with prior pull requests. We'll just need to target main and drop the next branch.

@jsumners
jsumners changed the base branch from next to main July 2, 2021 16:19
@MSE99

MSE99 commented Jul 2, 2021

Copy link
Copy Markdown
Contributor Author

@jsumners should i rebase back to main ?, since we're dropping the next branch.

@jsumners
jsumners merged commit 6968da2 into fastify:main Jul 2, 2021
@jsumners

jsumners commented Jul 2, 2021

Copy link
Copy Markdown
Member

@MSE99 sorry for all of the confusion. I fixed it up myself and got it merged.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Sep 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants