forked from taozhi8833998/node-sql-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate.js
More file actions
23 lines (20 loc) · 830 Bytes
/
generate.js
File metadata and controls
23 lines (20 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const fs = require('fs/promises')
const path = require('path')
const peggy = require('peggy')
const { readFile } = require('../common')
const config = require('../config')
const generate = async () => {
// Ensure output directory exists
const outputDir = path.resolve(__dirname, '../../lib/parser')
await fs.mkdir(outputDir, { recursive: true })
return await Promise.all(config.dialects.map(async dialect => {
const source = await readFile(path.resolve(__dirname, `../../pegjs/${dialect}-build.pegjs`))
const parser = peggy.generate(source, {
output : 'source',
format : 'commonjs',
disableRecursionCheck : process.argv.includes('--fast'),
})
return await fs.writeFile(path.resolve(outputDir, `${dialect}.js`), parser)
}))
}
exports.generate = generate