chore: make filename an options object to futureproof it

pull/13504/head
paoloricciuti 2 years ago
parent d08b0e405c
commit cfded9737a

@ -27,10 +27,10 @@ const style_placeholder = '/*$$__STYLE_CONTENT__$$*/';
* May throw an error if the code is too complex to migrate automatically.
*
* @param {string} source
* @param {string} [filename]
* @param {{filename?: string}} [options]
* @returns {{ code: string; }}
*/
export function migrate(source, filename) {
export function migrate(source, { filename } = {}) {
try {
// Blank CSS, could contain SCSS or similar that needs a preprocessor.
// Since we don't care about CSS in this migration, we'll just ignore it.

@ -14,7 +14,9 @@ const { test, run } = suite<ParserTest>(async (config, cwd) => {
.replace(/\s+$/, '')
.replace(/\r/g, '');
const actual = migrate(input, config.skip_filename ? undefined : `${cwd}/output.svelte`).code;
const actual = migrate(input, {
filename: config.skip_filename ? undefined : `${cwd}/output.svelte`
}).code;
// run `UPDATE_SNAPSHOTS=true pnpm test migrate` to update parser tests
if (process.env.UPDATE_SNAPSHOTS || !fs.existsSync(`${cwd}/output.svelte`)) {

@ -135,7 +135,7 @@ function compile({ id, source, options, return_ast }) {
/** @param {import("../workers").MigrateMessageData} param0 */
function migrate({ id, source, filename }) {
try {
const result = svelte.migrate(source, filename);
const result = svelte.migrate(source, { filename });
return {
id,

Loading…
Cancel
Save