github-tools / github-tools/github

Repository.writeFile fails if no options object is passed

未關閉
#577 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
JavaScript
星號
3.8k
分支
809
PR 合併指標
30 天內沒有已合併 PR

描述

In the [documentation](http://github-tools.github.io/github/docs/3.1.0/Repository.html#writeFile) about `Repository.writeFile`, the `options` parameter is specified as optional. Despite this, the function fails if no `options` object is passed and throws this error:
```
TypeError: Cannot read property 'encode' of undefined
at Repository.writeFile (/Users/lucasantchougov/Documents/Work/oauth-rule-manager/node_modules/github-api/dist/components/Repository.js:941:37)
at GitHubRuleManager.commitWorkspace (/Users/lucasantchougov/Documents/Work/oauth-rule-manager/lib/rule_managers/github-rule-manager.js:143:18)
at /Users/lucasantchougov/Documents/Work/matey/matey-server/app.js:74:25
at Layer.handle [as handle_request] (/Users/lucasantchougov/Documents/Work/matey/matey-server/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/lucasantchougov/Documents/Work/matey/matey-server/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/Users/lucasantchougov/Documents/Work/matey/matey-server/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/Users/lucasantchougov/Documents/Work/matey/matey-server/node_modules/express/lib/router/layer.js:95:5)
at /Users/lucasantchougov/Documents/Work/matey/matey-server/node_modules/express/lib/router/index.js:281:22
at param (/Users/lucasantchougov/Documents/Work/matey/matey-server/node_modules/express/lib/router/index.js:354:14)
at param (/Users/lucasantchougov/Documents/Work/matey/matey-server/node_modules/express/lib/router/index.js:365:14)
```

The error seems to get thrown when `options.encode` is read in `Repository.writeFile`. It only works for me when passing an empty object. This should be better documented or a default empty object should be instantiated in the method.

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。