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

Tests run twice if I add "test" to the pre-commit hook array in package.json #66

Open
Emuentes opened this issue Nov 13, 2015 · 13 comments
Labels

Comments

@Emuentes
Copy link

No description provided.

@nlf
Copy link
Owner

nlf commented Dec 8, 2015

your tests run twice? that's really weird. can you share your package.json with me?

also what version of precommit-hook and git-validate is this against?

@nlf nlf added the bug label Dec 8, 2015
@Emuentes
Copy link
Author

"precommit-hook": "^3.0.0"

npm list git-validate
[email protected]
└─┬ [email protected]
└── [email protected]

{
  "name": "m-app",
  "version": "1.0.0",
  "scripts": {
    "setup": "npm install && bower install",
    "start": "nodemon --debug server.js",
    "e2e:local": "protractor public/test/e2e/protractor-configurations-by-environment/protractor-local.conf.js",
    "e2e:qaa": "protractor public/test/e2e/protractor-configurations-by-environment/protractor-qaa.conf.js",
    "test": "gulp test"
  },
  "dependencies": {
    "async": "0.9.0",
    "body-parser": "1.8.4",
    "cookie-parser": "1.3.3",
    "ejs": "0.8.8",
    "express": "4.13.3",
    "underscore": "1.7.0",
    "wrench": "1.5.8",
  },
  "devDependencies": {
    "browser-sync": "^1.3.6",
    "chalk": "^0.4.0",
    "event-stream": "^3.3.1",
    "gulp": "^3.8.0",
    "gulp-angular-filesort": "^1.1.1",
    "gulp-autoprefixer": "^0.0.6",
    "gulp-babel": "^5.2.0",
    "gulp-cache": "^0.2.0",
    "gulp-concat": "2.4.3",
    "gulp-csso": "^0.2.6",
    "gulp-filter": "^1.0.0",
    "gulp-flatten": "^0.0.2",
    "gulp-inject": "^1.3.1",
    "gulp-jshint": "^1.8.0",
    "gulp-karma": "^0.0.4",
    "gulp-load-plugins": "^0.6.0",
    "gulp-minify-html": "^0.1.3",
    "gulp-ng-annotate": "^1.0.0",
    "gulp-ng-html2js": "^0.1.6",
    "gulp-nodemon": "^1.0.5",
    "gulp-protractor": "^0.0.11",
    "gulp-rename": "^1.2.2",
    "gulp-replace": "^0.4.0",
    "gulp-rev": "^1.1.0",
    "gulp-rev-replace": "^0.3.3",
    "gulp-rimraf": "^0.1.0",
    "gulp-sass": "^2.0.1",
    "gulp-size": "^1.1.0",
    "gulp-uglify": "^1.0.0",
    "gulp-useref": "^1.0.0",
    "gulp-util": "^3.0.4",
    "http-proxy": "^1.8.1",
    "https-proxy-agent": "^1.0.0",
    "jshint-stylish": "^0.4.0",
    "karma-coverage": "^0.3.1",
    "karma-jasmine": "~0.2.0",
    "karma-phantomjs-launcher": "^0.1.4",
    "karma-spec-reporter": "0.0.19",
    "main-bower-files": "^2.0.0",
    "moment": "^2.10.6"
    "precommit-hook": "^3.0.0",
    "protractor": "^2.2.0",
    "require-dir": "^0.1.0",
    "stream-series": "^0.1.1",
    "uglify-save-license": "^0.4.1",
    "wiredep": "^1.8.5",
    "yargs": "^3.7.2"
  },
  "engines": {
    "node": ">=0.10.0"
  },
  "pre-commit": [
    "test"
  ]
}

@Emuentes
Copy link
Author

$ git commit -m "testing pre-commit hook"
running test...passed!
running test...passed!

@Emuentes
Copy link
Author

If I remove "test" from the "pre-commit" array in package.json, the tests only fire once.

@nlf
Copy link
Owner

nlf commented Jan 22, 2016

ahhh, that's a good hint. ok, i'll investigate more.

@Emuentes
Copy link
Author

Just a wild guess, no research applied on my part, but I know that your module runs the NPM script named "test" if it isn't defined in the "pre-commit" array.

I haven't dug into the module code myself but if I dig around I'll be looking for the logic related to that on the theory that it's maybe not seeing "test" in my "pre-commit" array.

@Emuentes
Copy link
Author

When I rename "test" to "unit-test" in my "scripts" object, as is expected, it runs them both in succession.

"unit-test": "gulp test"

running test...passed!
running unit-test...passed!

I also tried adding "test": " echo 'this is a test' " to the scripts object and it was ignored.

Not sure if that's intended functionality.

@nlf
Copy link
Owner

nlf commented Jan 22, 2016

if you have an array set to pre-commit and it doesn't contain "test" then it should be ignored, so that's expected. what's strange is that you're still getting that double test. what operating system are you on? also what version of bash (bash --version)?

can you create a new empty repository and reproduce this issue in it? or does it only happen for one project?

@Emuentes
Copy link
Author

GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin14)
OSX 10.10.5 (Yosemite)

I haven't created an empty repo to test it yet but I have two similar projects & it happens in both.

I'll spin that empty repo up later today & get back to you brotha.

Thanks

@nlf
Copy link
Owner

nlf commented Jan 23, 2016

i just realized something.. do you happen to have two package.json files in your repo?

@Emuentes
Copy link
Author

Emuentes commented Feb 1, 2016

I do not.

I checked around hoping that I'd find a second one that someone on my team might have added inadvertently but other than the node_modules and a few bower_components, like Angular, I don't have more than one package.json

@Trott
Copy link
Collaborator

Trott commented Jul 3, 2018

@Emuentes I know it's been over two years, but is this still an issue? If so, I'd like to resume looking into it. If not, I'd like to close it...

@Emuentes
Copy link
Author

Emuentes commented Jul 4, 2018

@Trott I haven't utilized the module in a while, it may still be a thing, I could run a test with it on Thursday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants