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

Eror not finding files? #264

Closed
MrMamen opened this issue Sep 5, 2017 · 14 comments · Fixed by #255 or opencomponents/base-templates#128
Closed

Eror not finding files? #264

MrMamen opened this issue Sep 5, 2017 · 14 comments · Fixed by #255 or opencomponents/base-templates#128

Comments

@MrMamen
Copy link

MrMamen commented Sep 5, 2017

      const filenames = files.map(file => file.filename)
                             ^

TypeError: Cannot read property 'map' of undefined
    at sgf (/home/project/web/frontend/node_modules/lint-staged/src/runAll.js:33:30)
    at /home/project/web/frontend/node_modules/staged-git-files/index.js:13:13
    at /home/project/web/frontend/node_modules/staged-git-files/index.js:38:13
    at ChildProcess.<anonymous> (/home/project/web/frontend/node_modules/staged-git-files/index.js:88:9)
    at emitTwo (events.js:125:13)
    at ChildProcess.emit (events.js:213:7)
    at maybeClose (internal/child_process.js:897:16)
    at Socket.stream.socket.on (internal/child_process.js:340:11)
    at emitOne (events.js:115:13)
    at Socket.emit (events.js:210:7)

I've simplified the rules in package.json to:

  "lint-staged": {
    "*": [
    ]
  },

but it still gives the same error
I'm using "lint-staged": "4.1.0", "husky": "0.14.3",

@okonet
Copy link
Collaborator

okonet commented Sep 5, 2017

Thanks for reporting this. I think we have a regression.

@OmgImAlexis
Copy link

Same issue here.

husky > npm run -s precommit (node v8.4.0)

/Users/xo/code/lad/template/node_modules/lint-staged/src/runAll.js:33
      const filenames = files.map(file => file.filename)
                             ^

TypeError: Cannot read property 'map' of undefined
    at sgf (/Users/xo/code/lad/template/node_modules/lint-staged/src/runAll.js:33:30)
    at /Users/xo/code/lad/template/node_modules/staged-git-files/index.js:13:13
    at /Users/xo/code/lad/template/node_modules/staged-git-files/index.js:38:13
    at ChildProcess.<anonymous> (/Users/xo/code/lad/template/node_modules/staged-git-files/index.js:88:9)
    at emitTwo (events.js:125:13)
    at ChildProcess.emit (events.js:213:7)
    at maybeClose (internal/child_process.js:927:16)
    at Socket.stream.socket.on (internal/child_process.js:348:11)
    at emitOne (events.js:115:13)
    at Socket.emit (events.js:210:7)

husky > pre-commit hook failed (add --no-verify to bypass)

okonet pushed a commit that referenced this issue Sep 6, 2017
* test: Fix failing tests on windows(path compare)
* fix(runAll): Return from function on reject
* ci(appveyor): Disable shallow clone, enable cache
* fix: refactor jest mocks to fix blinking test

Closes #245
Closes #257
Closes #264
@okonet
Copy link
Collaborator

okonet commented Sep 6, 2017

I've just merged the fix. Please update to the latest version.

@OmgImAlexis
Copy link

@okonet updated and I'm still getting the same issue on OSX.

@sudo-suhas
Copy link
Collaborator

sudo-suhas commented Sep 6, 2017

@OmgImAlexis Could you share your lint-staged config? If you could help us reproduce this issue in a fresh project that would be very helpful.

Edit: @okonet Looks like there was a problem with semantic-release - https://travis-ci.org/okonet/lint-staged/jobs/272462973#L1966. A new version with the fixes was not released. Only the lodash fix in #265 was released in v4.1.1.

@OmgImAlexis
Copy link

  "lint-staged": {
    "*.{js,jsx,mjs,ts,tsx,css,less,scss,json,graphql}": [
      "prettier --write --single-quote --trailing-comma none",
      "git add"
    ],
    "*.md": [
      "remark . -qfo",
      "git add"
    ]
  },

PING: @niftylettuce

@sudo-suhas
Copy link
Collaborator

@okonet I identified the issue. The commits were squashed and merged with test: Fix failing tests on Windows (#255) which meant semantic-release thought there were no fixes in the commit.

@luftywiranda13
Copy link
Collaborator

but this is strange, i can comfirm that lint-staged v4.1.1 works just fine on my macbook.
I tested on small projects and also big projects

@okonet
Copy link
Collaborator

okonet commented Sep 6, 2017

@sudo-suhas okay let's release them as a part of a separate PR please.

@sudo-suhas
Copy link
Collaborator

It is actually an edge case where staged-git-files returns an error. Once scenario where this might happen is if the directory was not a git repository. But in such cases, the error should be propagated instead of breaking lint-staged.

@okonet
Copy link
Collaborator

okonet commented Sep 6, 2017

I'm not sure @sudo-suhas since we had issues related to sgf failing with this error before but I didn't see this issue yet.

@sudo-suhas
Copy link
Collaborator

If you see the stack trace carefully, you'll notice that the line number in staged-git-files when this error occurred was 38 which is an error callback. Which means we did not handle the error being returned by staged-git-files correctly. This was fixed though, just needs to be released.

let's release them as a part of a separate PR please.

I am not clear on what you mean. Could you please clarify?

@luftywiranda13
Copy link
Collaborator

@sudo-suhas okay let's release them as a part of a separate PR please.

empty commit should be fine, right? just to trigger semantic-release to release a patch release

@okonet
Copy link
Collaborator

okonet commented Sep 6, 2017

Fix is on the way!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment