{"action":"created","issue":{"url":"https://api.github.com/repos/serverless/serverless/issues/2809","repository_url":"https://api.github.com/repos/serverless/serverless","labels_url":"https://api.github.com/repos/serverless/serverless/issues/2809/labels{/name}","comments_url":"https://api.github.com/repos/serverless/serverless/issues/2809/comments","events_url":"https://api.github.com/repos/serverless/serverless/issues/2809/events","html_url":"https://github.com/serverless/serverless/pull/2809","id":191886213,"number":2809,"title":"Slstatsfix","user":{"login":"paulofla","id":3092458,"avatar_url":"https://avatars.githubusercontent.com/u/3092458?v=3","gravatar_id":"","url":"https://api.github.com/users/paulofla","html_url":"https://github.com/paulofla","followers_url":"https://api.github.com/users/paulofla/followers","following_url":"https://api.github.com/users/paulofla/following{/other_user}","gists_url":"https://api.github.com/users/paulofla/gists{/gist_id}","starred_url":"https://api.github.com/users/paulofla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulofla/subscriptions","organizations_url":"https://api.github.com/users/paulofla/orgs","repos_url":"https://api.github.com/users/paulofla/repos","events_url":"https://api.github.com/users/paulofla/events{/privacy}","received_events_url":"https://api.github.com/users/paulofla/received_events","type":"User","site_admin":false},"labels":[{"id":484058097,"url":"https://api.github.com/repos/serverless/serverless/labels/status/2-code-review","name":"status/2-code-review","color":"fad8c7","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-27T21:16:56Z","updated_at":"2016-12-08T14:38:51Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/serverless/serverless/pulls/2809","html_url":"https://github.com/serverless/serverless/pull/2809","diff_url":"https://github.com/serverless/serverless/pull/2809.diff","patch_url":"https://github.com/serverless/serverless/pull/2809.patch"},"body":"<!--\r\n1. Please check out and follow our Contributing Guidelines: https://github.com/serverless/serverless/blob/master/CONTRIBUTING.md\r\n2. Do not remove any section of the template. If something is not applicable leave it empty but leave it in the PR\r\n3. Please follow the template, otherwise we'll have to ask you to update it and it will take longer until your PR is merged\r\n-->\r\n\r\n## What did you implement:\r\n\r\nCloses #2784\r\n\r\n<!--\r\nBriefly describe the feature if no issue exists for this PR\r\n-->\r\n\r\n## How did you implement it:\r\n\r\nI moved the code to rename the stats file to a new function called createStatsFile.\r\nThis renames the current stats file or creates it if none has been created. If there is an error in writing the file or renaming the file, fse will throw an error. (I was being mindful of #1604 and #2313.)\r\n\r\nThe code won't throw an error if the file is not found as a new one should be created.\r\n\r\nI have moved all the code in the toggleStats method to the try, catch block so any error in the process is caught.\r\n\r\nI have added 2 tests and modified 1.\r\n1. Created a test for the creation of the stats file.\r\n2. Created a test if the current file exists and the same command is run again, that the file remains.\r\n3. Modified the error thrown test, so it will catch an example error message instead of the 'file not found' as that was misleading. A file not found means one should be created.\r\n\r\n## How can we verify it:\r\n\r\nRun `npm run test`.\r\nor\r\nRun `serverless slstats --enable` or `serverless slstats --disable`\r\n\r\n\r\n## Todos:\r\n\r\n- [x] Write tests\r\n- [x] Write documentation\r\n- [x] Fix linting errors\r\n- [x] Make sure code coverage hasn't dropped\r\n- [x] Provide verification config/commands/resources\r\n- [x] Enable [\"Allow edits from maintainers\"](https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork/) for this PR\r\n- [x] Change ready for review message below\r\n\r\n***Is this ready for review?:*** YES"},"comment":{"url":"https://api.github.com/repos/serverless/serverless/issues/comments/265754992","html_url":"https://github.com/serverless/serverless/pull/2809#issuecomment-265754992","issue_url":"https://api.github.com/repos/serverless/serverless/issues/2809","id":265754992,"user":{"login":"pmuens","id":1606004,"avatar_url":"https://avatars.githubusercontent.com/u/1606004?v=3","gravatar_id":"","url":"https://api.github.com/users/pmuens","html_url":"https://github.com/pmuens","followers_url":"https://api.github.com/users/pmuens/followers","following_url":"https://api.github.com/users/pmuens/following{/other_user}","gists_url":"https://api.github.com/users/pmuens/gists{/gist_id}","starred_url":"https://api.github.com/users/pmuens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pmuens/subscriptions","organizations_url":"https://api.github.com/users/pmuens/orgs","repos_url":"https://api.github.com/users/pmuens/repos","events_url":"https://api.github.com/users/pmuens/events{/privacy}","received_events_url":"https://api.github.com/users/pmuens/received_events","type":"User","site_admin":false},"created_at":"2016-12-08T14:38:51Z","updated_at":"2016-12-08T14:38:51Z","body":"Thanks @paulofla for the fix and @eahefnawy for reviewing it!\r\n\r\nI'll also review and test it tomorrow morning thoroughly so that we can merge it ASAP! 👍 "}}
{"actor":{"display_login":"pmuens"}}