Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

fix: add missing frameworks to main.js #57

Merged
merged 2 commits into from
Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/frameworks/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
const FRAMEWORKS = [
// Static site generators
require('./docusaurus.json'),
require('./docusaurus-v2.json'),
require('./eleventy.json'),
require('./gatsby.json'),
require('./gridsome.json'),
Expand All @@ -24,6 +25,7 @@ const FRAMEWORKS = [
require('./ember.json'),
require('./expo.json'),
require('./quasar.json'),
require('./quasar-v0.17.json'),
require('./sapper.json'),
require('./svelte.json'),
require('./vue.json'),
Expand Down
17 changes: 17 additions & 0 deletions test/frameworks.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
const fs = require('fs')
const path = require('path')
const util = require('util')

const Ajv = require('ajv')
const test = require('ava')
const { each } = require('test-each')

const { FRAMEWORKS } = require('../src/frameworks/main.js')

const pReadDir = util.promisify(fs.readdir)
const pReadFile = util.promisify(fs.readFile)

const ajv = new Ajv({})

const validate = function (value, schema) {
Expand Down Expand Up @@ -74,3 +81,13 @@ each(FRAMEWORKS, (info, framework) => {
t.is(validate(framework, FRAMEWORK_JSON_SCHEMA), true)
})
})

test('each json file should be required in main.js FRAMEWORKS', async (t) => {
const dir = path.join(__dirname, '..', 'src', 'frameworks')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[sand] In most cases, using forward slashes work on Windows, because almost all the Node.js API methods (like fs.readdir()) handle. Usually, path.join() only matters when the file path is output to a file or a terminal, or is a binary executed in the terminal. See some write-up on this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed in a6084a8

const jsonFiles = (await pReadDir(dir)).filter((file) => path.extname(file) === '.json')

const mainFile = await pReadFile(path.join(dir, 'main.js'), 'utf8')

const missing = jsonFiles.filter((file) => !mainFile.includes(`./${file}`))
t.deepEqual(missing, [])
})