-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
yarn-support #488
Merged
Merged
yarn-support #488
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f0a56d1
get template by name
mattiaerre f289a5c
fix test
mattiaerre ab7e7bb
Merge branch 'master' into yarn-support
mattiaerre 66fa535
use mocha
mattiaerre bdc3b1b
remove jest
mattiaerre 035dae2
consolidate test
mattiaerre 085b4e6
no destructuring
mattiaerre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
__tests__/src/utils/__snapshots__/require-template.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`requireTemplate not valid lodash 1`] = `"Error requiring oc-template: \\"lodash\\" is not a valid oc-template"`; | ||
|
||
exports[`requireTemplate not valid oc-invalid-template 1`] = `"Error requiring oc-template: \\"oc-invalid-template\\" not found"`; | ||
|
||
exports[`requireTemplate valid oc-template-handlebars 1`] = ` | ||
Object { | ||
"compile": [Function], | ||
"getCompiledTemplate": [Function], | ||
"getInfo": [Function], | ||
"render": [Function], | ||
} | ||
`; | ||
|
||
exports[`requireTemplate valid oc-template-jade 1`] = ` | ||
Object { | ||
"compile": [Function], | ||
"getCompiledTemplate": [Function], | ||
"getInfo": [Function], | ||
"render": [Function], | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const requireTemplate = require('../../../src/utils/require-template'); | ||
|
||
describe('requireTemplate', () => { | ||
test('expect type of `requireTemplate` to be function', () => { | ||
expect(typeof requireTemplate).toBe('function'); | ||
}); | ||
|
||
describe('valid', () => { | ||
const scenarios = [ | ||
{ name: 'oc-template-handlebars' }, | ||
{ name: 'oc-template-jade' } | ||
]; | ||
|
||
scenarios.forEach(({ name }) => { | ||
test(name, () => { | ||
const template = requireTemplate(name); | ||
|
||
['compile', 'getCompiledTemplate', 'getInfo', 'render'] | ||
.forEach((method) => { | ||
expect(template).toHaveProperty(method); | ||
}); | ||
expect(template).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('not valid', () => { | ||
const scenarios = [ | ||
{ name: 'lodash' }, | ||
{ name: 'oc-invalid-template' } | ||
]; | ||
|
||
scenarios.forEach(({ name }) => { | ||
test(name, () => { | ||
const sut = () => { | ||
requireTemplate(name); | ||
}; | ||
|
||
expect(sut).toThrow(); | ||
expect(sut).toThrowErrorMatchingSnapshot(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the only "new" code I've added that tries to fix the yarn issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about my ignorance, but how can that change affect over the yarn installation behavior? I only see you moved the logic to a function 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
Yes I moved the logic into a function but I've also added an additional check of getting the template by name (line 35).
Try to do this: install OC globally w/ yarn and make sure your publish doesn't work. Then replace require-template.js in the yarn OC global folder w/ the file I've changed and see if that fixes. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just tried it, and I can't publish due to this: npm/npmlog#48
😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is another problem; you need to rm -rf node_modules first, it is a known issue w/ npmlog when switching between npm and yarn 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was doing it now... and then I face with this...
After seeing the error... I thought that maybe your changes now could allow me to publish from the widget folder itself, so I tried:
the neverending story... 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
infinite-loop-loader
tells us everything hehehe 😊 feel free to collaborate on this branch; I will not be able to follow this issue as I'll be offline for a couple of days but either @matteofigus or @nickbalestra should be able to have a look at this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After manually installing
infinite-loop-loader
(ofc only for this test) everything works as expected! 😃There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very good; we are getting there 😉 thanks for your help!
// cc @matteofigus @nickbalestra