-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.test.js
More file actions
21 lines (20 loc) · 802 Bytes
/
config.test.js
File metadata and controls
21 lines (20 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import fs from 'fs/promises'
import flowRemoveTypes from 'flow-remove-types'
/**
* Transpiles Flow files to JavaScript, the weakness of this implementation is that it doesn't support
* bundling, so it doesn't work with other flow files.
* Pineapple expects all transpilation functions to export a bundle.
* @pineapple_transpile ['*.flow.js']
* @param {string} file
* @param {string} recommended
*/
export async function transpileFlow (file, recommended) {
const output = flowRemoveTypes(await fs.readFile(file, { encoding: 'utf-8' }))
const map = output.generateMap()
map.sources = [file]
await fs.writeFile(
recommended,
`${output.toString()}\n//# sourceMappingURL=data:application/json;base64,${Buffer.from(JSON.stringify(map)).toString('base64')}`
)
return recommended
}