Skip to content
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

Merged
merged 5 commits into from Oct 10, 2019
Merged

chore(karma): improve fixtures generation #653

merged 5 commits into from Oct 10, 2019

Conversation

P0lip
Copy link
Contributor

@P0lip P0lip commented Oct 8, 2019

Needed for #635

@P0lip P0lip added the chore label Oct 8, 2019
@P0lip P0lip self-assigned this Oct 8, 2019
@P0lip P0lip force-pushed the chore/karma branch 2 times, most recently from 06962fe to fbd688f Compare October 8, 2019 17:49
@nulltoken
Copy link
Contributor

@P0lip I've rebase #635 on top of your branch. Works like a charm. No more warnings.

image

@P0lip P0lip requested a review from XVincentX October 10, 2019 13:15
Copy link
Contributor

@XVincentX XVincentX left a 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__/
Copy link
Contributor

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`);
Copy link
Contributor

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?

Copy link
Contributor Author

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));
Copy link
Contributor

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?

Copy link
Contributor Author

@P0lip P0lip Oct 10, 2019

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

@P0lip P0lip merged commit 59d3531 into develop Oct 10, 2019
@P0lip P0lip deleted the chore/karma branch October 10, 2019 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants