fix: hide node_modules and vendor from update output (#3089)
Added logic to filter out files in node_modules and vendor directories from user-facing logs and migration summaries in the update process. Updated tests to verify that these files are processed but not shown in logs. close #3082 --------- Co-authored-by: 李嘉图·M·路 <146103794+Ricardo-M-Zheng@users.noreply.github.com> Co-authored-by: Marvin Hagemeister <marvinhagemeister50@gmail.com>
This commit is contained in:
co-authored by
李嘉图·M·路
Marvin Hagemeister
parent
3c43d98a57
commit
31dcbfbb8b
@@ -6,6 +6,7 @@ import {
|
||||
updateProject,
|
||||
} from "./update.ts";
|
||||
import { expect } from "@std/expect";
|
||||
import { spy, type SpyCall } from "@std/testing/mock";
|
||||
import { walk } from "@std/fs/walk";
|
||||
import { withTmpDir } from "../../src/test_utils.ts";
|
||||
|
||||
@@ -703,3 +704,54 @@ Deno.test("update - island files", async () => {
|
||||
`import { IS_BROWSER } from "fresh/runtime";`,
|
||||
);
|
||||
});
|
||||
|
||||
Deno.test("update - ignores node_modules and vendor in logs", async () => {
|
||||
await using _tmp = await withTmpDir();
|
||||
const dir = _tmp.dir;
|
||||
await writeFiles(dir, {
|
||||
"/deno.json": `{}`,
|
||||
"/routes/index.tsx": `import { PageProps } from "$fresh/server.ts";
|
||||
export default function Foo(props: PageProps) {
|
||||
return null;
|
||||
}`,
|
||||
"/node_modules/foo/bar.ts":
|
||||
`import { IS_BROWSER } from "$fresh/runtime.ts";`,
|
||||
"/vendor/foo/bar.ts": `import { IS_BROWSER } from "$fresh/runtime.ts";`,
|
||||
});
|
||||
|
||||
const consoleLogSpy = spy(console, "log");
|
||||
|
||||
try {
|
||||
await updateProject(dir);
|
||||
} finally {
|
||||
consoleLogSpy.restore();
|
||||
}
|
||||
|
||||
const files = await readFiles(dir);
|
||||
|
||||
expect(files["/node_modules/foo/bar.ts"]).toEqual(
|
||||
`import { IS_BROWSER } from "fresh/runtime";`,
|
||||
);
|
||||
expect(files["/vendor/foo/bar.ts"]).toEqual(
|
||||
`import { IS_BROWSER } from "fresh/runtime";`,
|
||||
);
|
||||
expect(files["/routes/index.tsx"]).toEqual(
|
||||
`import { PageProps } from "fresh";
|
||||
export default function Foo(props: PageProps) {
|
||||
return null;
|
||||
}`,
|
||||
);
|
||||
|
||||
const fullLog = consoleLogSpy.calls.map((call: SpyCall) =>
|
||||
call.args.join(" ")
|
||||
).join(
|
||||
"\n",
|
||||
);
|
||||
|
||||
expect(fullLog).toMatch(/Total files processed: 1/);
|
||||
expect(fullLog).toMatch(/Successfully modified: 1/);
|
||||
expect(fullLog).toMatch(/Unmodified \(no changes needed\): 0/);
|
||||
expect(fullLog).not.toMatch(/node_modules/);
|
||||
expect(fullLog).not.toMatch(/vendor/);
|
||||
expect(fullLog).toMatch(/✓ routes\/index.tsx/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user