You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/js/update.ts

30 lines
741 B

import {replaceIfUpdated } from "../tiny-glob";
// this file will replace all the expected.js files with their _actual
// equivalents. Only use it when you're sure that you haven't
// broken anything!
function loadConfig(file) {
try {
const resolved = require.resolve(file);
delete require.cache[resolved];
const config = require(resolved);
return config.default || config;
} catch (err) {
if (err.code === "MODULE_NOT_FOUND") {
return {};
}
throw err;
}
}
replaceIfUpdated((compile, check, get_relative) => {
check(
"expected.js",
compile(loadConfig(get_relative("_config.js")).options).js.code.replace(
/generated by Svelte v\d+\.\d+\.\d+(-\w+\.\d+)?/,
"generated by Svelte vX.Y.Z"
)
);
}, __dirname);