mirror of
https://github.com/hanzoai/forum.git
synced 2026-09-30 21:51:19 +00:00
TIL: `require._eak_seen` is an old alias for `require.entries` and it comes from Ember App Kit (a blast from the past!)
25 lines
700 B
JavaScript
25 lines
700 B
JavaScript
export default function (helpers) {
|
|
const { response } = helpers;
|
|
const fixturesByUrl = {};
|
|
|
|
// Load any fixtures automatically
|
|
Object.keys(require.entries).forEach((entry) => {
|
|
if (/^discourse\/tests\/fixtures/.test(entry)) {
|
|
const fixture = require(entry, null, null, true);
|
|
if (fixture && fixture.default) {
|
|
const obj = fixture.default;
|
|
Object.keys(obj).forEach((url) => {
|
|
let fixtureUrl = url;
|
|
if (fixtureUrl[0] !== "/") {
|
|
fixtureUrl = "/" + fixtureUrl;
|
|
}
|
|
fixturesByUrl[url] = obj[url];
|
|
this.get(fixtureUrl, () => response(obj[url]));
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
return fixturesByUrl;
|
|
}
|