Move the base CodeMirror KCL support to a local package (#4897)
* Move CodeMirror LRLanguage to new file This separates the base language support from the LSP and color picker. * Move the base CodeMirror KCL support to a local package * Start CodeMirror grammar tests * Exclude vitest config in tsconfig * Add KCL path to tsconfig * Remove stray import * Drop extension from import * Use __filename for commonjs compat * Check exec return before access * Build ES and CJS to dist * Format * Exclude all.test.ts from codespell This is to work around "fileTests" imported from Lezer. Future codespell versions look like they'll allow the code to be annotated, which would be nicer. --------- Co-authored-by: Matt Mundell <matt@mundell.me>
This commit is contained in:
22
packages/codemirror-lang-kcl/test/all.test.ts
Normal file
22
packages/codemirror-lang-kcl/test/all.test.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { KclLanguage } from '../src/index'
|
||||
import { fileTests } from '@lezer/generator/dist/test'
|
||||
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
|
||||
let caseDir = path.dirname(__filename)
|
||||
|
||||
for (let file of fs.readdirSync(caseDir)) {
|
||||
if (!/\.txt$/.test(file)) continue
|
||||
|
||||
let fname = /^[^\.]*/.exec(file)?.at(0)
|
||||
if (fname) {
|
||||
let tests = fileTests(
|
||||
fs.readFileSync(path.join(caseDir, file), 'utf8'),
|
||||
file
|
||||
)
|
||||
describe(fname, () => {
|
||||
for (let { name, run } of tests) it(name, () => run(KclLanguage.parser))
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user