(filePath, manipulateSourceFn)
| 10 | } |
| 11 | |
| 12 | export async function processFile (filePath, manipulateSourceFn) { |
| 13 | return new Promise((resolve, reject) => { |
| 14 | fs.readFile(filePath, 'utf8', (error, rawSource) => { |
| 15 | if (error) { |
| 16 | return reject(error) |
| 17 | } |
| 18 | const output = manipulateSourceFn(rawSource) |
| 19 | fs.writeFile(filePath, output, (error) => { |
| 20 | if (error) { |
| 21 | return reject(error) |
| 22 | } |
| 23 | resolve() |
| 24 | }) |
| 25 | }) |
| 26 | }) |
| 27 | } |
| 28 | |
| 29 | export function readFile (filePath, options = 'utf-8') { |
| 30 | return fs.readFileSync(filePath, options) |
no outgoing calls
no test coverage detected