Skip to content

Fix example by forcing backslashes with path.posix#1346

Merged
implausible merged 1 commit into
nodegit:masterfrom
rcjsuen:posix-path
Dec 20, 2017
Merged

Fix example by forcing backslashes with path.posix#1346
implausible merged 1 commit into
nodegit:masterfrom
rcjsuen:posix-path

Conversation

@rcjsuen
Copy link
Copy Markdown
Member

@rcjsuen rcjsuen commented Aug 6, 2017

A user reported in #1339 that an error will occur if you try to run the examples/add-and-commit.js example on Windows.

$ node add-and-commit.js
nodegit\node_modules\nodegit-promise\lib\done.js:10
      throw err;
      ^

Error: invalid path: 'salad\toast\strangerinastrangeland\theresnowaythisexists\newfile.txt'
    at Error (native)

This is because addByPath from of Index seems to only accept paths with forward slashes. Replacing the path.join with path.posix.join will resolve the problem.

Index's addByPath function does not accept backslashes. To ensure
that forward slashes are used, path.posix is used to join paths
together with a forward slash in a platform independent way.

Signed-off-by: Remy Suen <[email protected]>
@saper
Copy link
Copy Markdown
Collaborator

saper commented Aug 6, 2017

Thanks! Can you writer a little test for this one?

@rcjsuen
Copy link
Copy Markdown
Member Author

rcjsuen commented Aug 6, 2017

@saper Sorry, I don't understand. What would be added to the test suite?

@rcjsuen
Copy link
Copy Markdown
Member Author

rcjsuen commented Nov 9, 2017

Someone got hit by this again today. Can we get this merged in so that the example is fixed?

@saper Could you describe what you meant by the addition of a test?

@implausible implausible merged commit 751c0e5 into nodegit:master Dec 20, 2017
@rcjsuen rcjsuen deleted the posix-path branch December 20, 2017 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants