mirror of
https://github.com/actualbudget/actual.git
synced 2026-05-07 12:28:57 -05:00
Hi there, `Peg.js` is unmaintained, so I figure you all would appreciate if I replaced it with the drop-in replacement of Peggy. This is work I am breaking out of #918. Peggy adds new features like source map support that we could use, although I do not include that in this change-set. It may be useful for debugging changes to the .pegjs file we have.e
25 lines
584 B
JavaScript
25 lines
584 B
JavaScript
// A peggy version of the pegjs-jest-transformer
|
|
// Transforms .pegjs compliant files to JS code.
|
|
|
|
import * as crypto from 'crypto';
|
|
|
|
import peg from 'peggy';
|
|
|
|
const transform = {
|
|
process(sourceText, sourcePath, _options) {
|
|
return `module.exports = ${peg.generate(sourceText, {
|
|
output: 'source-with-inline-map',
|
|
grammarSource: sourcePath,
|
|
})}`;
|
|
},
|
|
getCacheKey(sourceText, _sourcePath, options) {
|
|
return crypto
|
|
.createHash('md5')
|
|
.update(sourceText)
|
|
.update(options.configString)
|
|
.digest('hex');
|
|
},
|
|
};
|
|
|
|
export default transform;
|