{"id":13414782,"url":"https://github.com/dflourusso/pre-push","last_synced_at":"2025-04-04T23:10:00.781Z","repository":{"id":33422548,"uuid":"37067819","full_name":"dflourusso/pre-push","owner":"dflourusso","description":"Add a pre-push git hook","archived":false,"fork":false,"pushed_at":"2024-06-10T14:07:19.000Z","size":47,"stargazers_count":126,"open_issues_count":3,"forks_count":22,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T22:14:21.447Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dflourusso.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-06-08T13:14:37.000Z","updated_at":"2024-06-30T09:11:52.000Z","dependencies_parsed_at":"2024-01-15T23:26:52.594Z","dependency_job_id":"ef67aaa9-f9c4-4f61-bba4-ca7cec98aa17","html_url":"https://github.com/dflourusso/pre-push","commit_stats":{"total_commits":19,"total_committers":11,"mean_commits":"1.7272727272727273","dds":0.736842105263158,"last_synced_commit":"838cf7a9cdcd470b19ec61924f81ccfcef85ab08"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dflourusso%2Fpre-push","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dflourusso%2Fpre-push/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dflourusso%2Fpre-push/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dflourusso%2Fpre-push/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dflourusso","download_url":"https://codeload.github.com/dflourusso/pre-push/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247261612,"owners_count":20910108,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T21:00:36.616Z","updated_at":"2025-04-04T23:10:00.765Z","avatar_url":"https://github.com/dflourusso.png","language":"JavaScript","readme":"# pre-push\n\n\n\u003cp\u003e\n  \u003ca href=\"https://www.npmjs.com/package/pre-push\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/pre-push.svg\" alt=\"Downloads\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/pre-push\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/pre-push.svg\" alt=\"Version\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/pre-push\"\u003e\u003cimg src=\"https://img.shields.io/npm/l/pre-push.svg\" alt=\"License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n**pre-push** is a pre-push hook installer for `git`. It will ensure that\nyour `npm test` (or other specified scripts) passes before you can push your\nchanges. This all conveniently configured in your `package.json`.\n\nBut don't worry, you can still force a push by telling `git` to skip the\n`pre-push` hooks by simply pushing using `--no-verify`.\n\n### Installation\n\nIt's advised to install the **pre-push** module as a `devDependencies` in your\n`package.json` as you only need this for development purposes. To install the\nmodule simply run:\n\n```\nnpm install --save-dev pre-push\n```\n\nor \n\n```\nyarn add -D pre-push\n```\n\nTo install it as `devDependency`. When this module is installed it will override\nthe existing `pre-push` file in your `.git/hooks` folder. Existing\n`pre-push` hooks will be backed up as `pre-push.old` in the same repository.\n\n### Configuration\n\n`pre-push` will try to run your `npm test` command in the root of the git\nrepository by default unless it's the default value that is set by the `npm\ninit` script.\n\nBut `pre-push` is not limited to just running your `npm test`'s during the\npush hook. It's also capable of running every other script that you've\nspecified in your `package.json` \"scripts\" field. So before people push you\ncould ensure that:\n\n- You have 100% coverage\n- All styling passes.\n- JSHint passes.\n- Contribution licenses signed etc.\n\nThe only thing you need to do is add a `pre-push` array to your `package.json`\nthat specifies which scripts you want to have ran and in which order:\n\n```js\n{\n  \"name\": \"437464d0899504fb6b7b\",\n  \"version\": \"0.0.0\",\n  \"description\": \"ERROR: No README.md file found!\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"test\": \"echo \\\"Error: I SHOULD FAIL LOLOLOLOLOL \\\" \u0026\u0026 exit 1\",\n    \"foo\": \"echo \\\"fooo\\\" \u0026\u0026 exit 0\",\n    \"bar\": \"echo \\\"bar\\\" \u0026\u0026 exit 0\"\n  },\n  \"pre-push\": [\n    \"foo\",\n    \"bar\",\n    \"test\"\n  ]\n}\n```\n\nIn the example above, it will first run: `npm run foo` then `npm run bar` and\nfinally `npm run test` which will make the push fail as it returns the error\ncode `1`.  If you prefer strings over arrays or `prepush` without a middle\ndash, that also works:\n\n```js\n{\n  \"prepush\": \"foo, bar, test\"\n  \"pre-push\": \"foo, bar, test\"\n  \"pre-push\": [\"foo\", \"bar\", \"test\"]\n  \"prepush\": [\"foo\", \"bar\", \"test\"],\n  \"prepush\": {\n    \"run\": \"foo, bar, test\",\n  },\n  \"pre-push\": {\n    \"run\": [\"foo\", \"bar\", \"test\"],\n  },\n  \"prepush\": {\n    \"run\": [\"foo\", \"bar\", \"test\"],\n  },\n  \"pre-push\": {\n    \"run\": \"foo, bar, test\",\n  }\n}\n```\n\nThe examples above are all the same. In addition to configuring which scripts\nshould be ran you can also configure the following options:\n\n- **silent** Don't output the prefixed `pre-push:` messages when things fail\n  or when we have nothing to run. Should be a boolean.\n- **colors** Don't output colors when we write messages. Should be a boolean.\n- **template** Path to a file who's content should be used as template for the\n  git push body.\n\nThese options can either be added in the `pre-push`/`prepush` object as keys\nor as `\"pre-push.{key}` key properties in the `package.json`:\n\n```js\n{\n  \"prepush.silent\": true,\n  \"pre-push\": {\n    \"silent\": true\n  }\n}\n```\n\nIt's all the same. Different styles so use what matches your project. To learn\nmore about the scripts, please read the official `npm` documentation:\n\nhttps://npmjs.org/doc/scripts.html\n\nAnd to learn more about git hooks read:\n\nhttp://githooks.com\n\n### License\n\nMIT\n","funding_links":[],"categories":["An Node JS supercool REST API","Productivity"],"sub_categories":["React Components"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdflourusso%2Fpre-push","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdflourusso%2Fpre-push","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdflourusso%2Fpre-push/lists"}