feat: Adds a resolved path for output#80
Conversation
okonet
left a comment
There was a problem hiding this comment.
LGTM in general. See my comments.
| describe('getRequire', () => { | ||
| it('should create a require statement', () => { | ||
| const require = utils.getRequire(j, 'filesys', 'fs'); | ||
| expect(require).toMatchSnapshot(); |
There was a problem hiding this comment.
This should probably create snapshot for the source code. Right now it's for AST.
expect(require.toSource()).toMatchSnapshot()?
There was a problem hiding this comment.
Fragments dont actually have .toSource() on them. :( Will try to figure out if this is possible some other way. I think I should be able to convert it to a node somehow.
| const path = require('path'); | ||
| module.exports = { | ||
| output: { | ||
| path: path.join(__dirname, 'dist') |
There was a problem hiding this comment.
Should we add a test where path is imported as a variable with a different name?
const p = require('path') should also work I guess.
There was a problem hiding this comment.
Oh yeah, what is path is required in the file but output doesnnt use it? Need to add some more checks.
| }, false)); | ||
| if (pathDecalaration) { | ||
| isPathPresent = true; | ||
| pathDecalaration.forEach(p => {pathVarName = utils.safeTraverse(p, ['value', 'id', 'name']);}); |
There was a problem hiding this comment.
Let's put the block code on a new line please. This is hard to read now.
| isPathPresent = true; | ||
| pathDecalaration.forEach(p => {pathVarName = utils.safeTraverse(p, ['value', 'id', 'name']);}); | ||
| } | ||
| console.log(pathVarName); |
There was a problem hiding this comment.
Let's remove console.log calls please.
| pathDecalaration.forEach(p => {pathVarName = utils.safeTraverse(p, ['value', 'id', 'name']);}); | ||
| } | ||
| console.log(pathVarName); | ||
| literalOutputPath.find(j.Literal) |
There was a problem hiding this comment.
Should the .find() be also a new line?
|
Hey @okonet - Thanks for the detailed review. I've taken care of the changes. |
|
Feel free to squash & merge with the commitizen-compatible commit message! |
* feat: Adds a resolved path for output * fix * fix: Add review fix * fix: test for source not ast * fix: review comments
What kind of change does this PR introduce?
This tries to address #73
Did you add tests for your changes?
Yep
If relevant, did you update the documentation?
NA
Summary
To summarise, it tries to implement what was promised in #73