mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-22 00:13:45 -05:00
28 lines
675 B
JavaScript
28 lines
675 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 = {
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
process(sourceText, sourcePath, _options) {
|
|
return {
|
|
code: `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;
|