elm-review
Version:
Run elm-review from Node.js
32 lines (25 loc) • 731 B
JavaScript
/**
* @import {Path} from './types/path';
* @import {ReviewModule} from './types/app';
*/
const path = require('node:path');
module.exports = loadCompiledElmApp;
let hasBeenPatchedAlready = false;
/**
* @param {Path} elmModulePath
* @returns {ReviewModule}
*/
function loadCompiledElmApp(elmModulePath) {
if (!hasBeenPatchedAlready) {
const oldConsoleWarn = console.warn;
const regex = /^Compiled in DE(BUG|V) mode/;
console.warn = function (...args) {
if (args.length === 1 && regex.test(args[0])) return;
oldConsoleWarn.apply(console, args);
};
hasBeenPatchedAlready = true;
}
/** @type {ReviewModule} */
const elmApp = require(path.resolve(elmModulePath));
return elmApp;
}