scratch-storage/test/transformers/arraybuffer-loader.js
Christopher Willis-Ford 322ae0b166 test: fix transformer for backslashes
Injecting the path into the "code" was causing the backslashes to be
interpreted as escape characters instead of path separators. I could
have escaped them, but this approach is more similar to what Webpack
does with `arraybuffer-loader` and (IMO) easier to read.
2023-05-02 14:57:36 -07:00

11 lines
281 B
JavaScript

const fs = require('fs');
module.exports = {
process (_sourceText, sourcePath) {
const buffer = fs.readFileSync(sourcePath);
const array = buffer.toJSON().data;
return {
code: `module.exports = Buffer.from([${array}]);`
};
}
};