Added ES6 Snippet support for NodeJS-Request#164
Added ES6 Snippet support for NodeJS-Request#164sastava007 wants to merge 3 commits intopostmanlabs:developfrom sastava007:develop
Conversation
|
Hey! Thanks for the contribution. @sastava007 |
|
@umeshp7 Thanks for your feedback, I was also thinking of the same changes. |
|
@sastava007 yes, this would be similar to how other options are used while generating snippet. Add it to the options array defined in getOptions() function, and then use the option everywhere you need to generate ES6 enabled snippet. Add the support via options now, the default value can be decided later. |
…cture.test.js file to respect the new changes
|
@umeshp7 @shreys7 Please review! |
|
@sastava007 Okay, we'll review. Could you also update the description of this PR to describe the changes you have done now? |
|
@umeshp7 Updated! |
|
@sastava007 need unit tests around this to verify the generated snippet with option set to true/false |
|
@shreys7 Have added, please review. |
shreys7
left a comment
There was a problem hiding this comment.
Do we really need a new variable called ES6_snippet? Can't we keep just one snippet variable and make some required changes according to the ES6_enabled option's value, as I see a lot of code being repeated for generating snippet and ES6_snippet.
| optionsArray.push(indentString + 'followRedirect: false'); | ||
| } | ||
| if (options.ES6_enabled === true) { | ||
| optionsArray.push(indentString + 'ES6_enabled: true'); |
There was a problem hiding this comment.
@shreys7
I thought that it would be better to have a separate snippet for ES6 instead of using bunch of if statements. But, no problem I'll make it with single snippet only.
And for this,
if (options.ES6_enabled === true) {
optionsArray.push(indentString + 'ES6_enabled: true');
I have mistaken this and thought that we need to pass it to options property, but just I realized that it's only required till the snippet is generated and after that, it's of no use.
I'll fix all this, and made a separate PR by deleting this one.
There was a problem hiding this comment.
@sastava007 Hmm, I see. See if you can reduce the number of if statements. If that's causing a lot of if-else statements, then we can go with your approach.
| } | ||
|
|
||
| expect(snippet).to.be.a('string'); | ||
| expect(snippet).to.include('ES6_enabled: true'); |
There was a problem hiding this comment.
again, why does this need to be included in the generated snippet? @sastava007
| } | ||
|
|
||
| expect(snippet).to.be.a('string'); | ||
| expect(snippet).to.not.include('ES6_enabled: true'); |
| ES6_snippet += 'const fs = require(\'fs\');\n'; | ||
| } | ||
| snippet += 'var options = {\n'; | ||
| ES6_snippet += 'const options = {\n'; |
There was a problem hiding this comment.
This should be var or more preferably let instead of const options
|
The changes requested should have been updated on this PR itself for the purposes of keeping proper track of the progress. |
|
Actually, I pushed those commits directly to the default develop branch itself. Because of which whenever I create any new branch for resolving other features/issue all the previous commits were also showing in it. So I thought that it would be better if I delete that PR and start again with a dedicated branch to a particular issue this would help me to keep working on the different issues until a previous one is under review. |
What it does
Allows the user to generate the code snippet for NodeJS Request in ES6 format.
This is in response to issue #115 requested by one of the users.
Changes I made
Created a new folder under./codegensnamednodejs-requestES6which contains all the code for making requests along withnewmanandunit testfiles.Registered a new parameter ES6_enabled in
options()which allows the user to toggle between whether codegen generate snippet with ES6 features or not.By default ES6_enabled is set to
falseAlso added the new created option parameter in
structure.test.jsfile to register it as a valid option id.Added unit tests to verify the generated snippets.
Follow Up
This PR is first in the series of upcoming PRs which will add the feature of generating code snippet in ES6 notation with NodeJS.
@abhijitkane @shreys7 Please review!