-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
30 lines (25 loc) · 763 Bytes
/
build.js
File metadata and controls
30 lines (25 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import * as fs from 'fs'
import * as path from 'path'
import get_files from './get_files.js'
const files = [
...get_files('./helpers'),
...get_files('./types'),
...get_files('./tables'),
...get_files('./triggers'),
]
let content = ''
for (const i in files) {
const filepath = files[i]
const data = fs.readFileSync(filepath, 'utf8')
const title = path.parse(filepath).name.toUpperCase()
const header =
`/*
=================== ${title} ===================
*/\n`
content += header + data
}
const name = process.env.npm_package_name
const version = process.env.npm_package_version
const filepath = `./dist/${name}--${version}.sql`
fs.writeFileSync(filepath, content, 'utf8')
console.log('the file is generated and located in ' + filepath)