-
-
Notifications
You must be signed in to change notification settings - Fork 234
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
chore(karma): improve fixtures generation #653
Conversation
06962fe
to
fbd688f
Compare
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.
To be honest I do not really get what's going on here and the original PR is too huge to take a look at it, but I'll not block this.
@@ -7,7 +7,7 @@ | |||
|
|||
/binaries | |||
/rulesets | |||
/src/__tests__/__fixtures__/oas-functions.json | |||
/__karma__/__fixtures__/ |
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.
Doesn't this require a git rm -r --cached .
to make sure to remove the old files from the index?
const files = fs.readdirSync(fnsPath); | ||
for (const spec of ['', '2', '3']) { | ||
const target = path.join(baseDir, `oas${spec}-functions.json`); | ||
const fnsPath = path.join(__dirname, `../rulesets/oas${spec}/functions`); |
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.
What does fns
stand for?
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.
functions
|
||
fs.writeFileSync(target, JSON.stringify(bundledFns, null, 2)) | ||
fs.writeFileSync(target, JSON.stringify(bundledFns, null, 2)); |
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.
If I understand correctly what this function is doing is reading 3 files and then write all of them back in a single file?
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.
Almost.
It reads contents of 3 directories, namely /src/rulesets/oas/functions
, /src/rulesets/oas2/functions
, /src/rulesets/oas3/functions
and the files located there.
Then, it reads each file, and assigns its content to the property, and eventually all files located in a given directory gets saved to a single json (oas-function.json
or oas2-functions.json
or oas3-functions.json
).
This is needed only for Karma tests. The files are imported here https://github.com/stoplightio/spectral/pull/653/files/31f24d2c70187af125e651b2f2ef9b0462638d91#diff-803b3736a08e0afcf28f5dac4102eeb7R10-R13
Needed for #635