Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"devDependencies": {
"@astrojs/sitemap": "^3.7.0",
"@rslib/core": "0.19.4",
"@rstest/core": "^0.8.2",
"@rstest/core": "https://pkg.pr.new/web-infra-dev/rstest/@rstest/core@7b64c24bad5a4691753ee91eb695bba40e7cf1be",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Using a direct URL to a specific commit for a dependency is not recommended for merging into a main branch. This approach is brittle, as the commit can become unavailable, and it bypasses standard package versioning, making dependency management and security auditing difficult. While this might be acceptable for temporary CI testing, it should be reverted to a proper version from a package registry before merging.

"@types/fs-extra": "^11.0.4",
"@types/node": "22.19.8",
"chalk": "^5.6.2",
Expand Down
26 changes: 7 additions & 19 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tests/prebundle.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { afterAll, beforeAll, describe, expect, it, rs } from '@rstest/core';
import { afterAll, beforeAll, describe, expect, it } from '@rstest/core';
import { execFile } from 'node:child_process';
import { promises as fs, readdirSync } from 'node:fs';
import { join, relative, sep } from 'node:path';
Expand All @@ -19,13 +19,13 @@ const targetPackages: TargetPackage[] = [
{
name: 'chalk',
verify: async (distPath: string) => {
rs.stubEnv('FORCE_COLOR', '1');
// rs.stubEnv('FORCE_COLOR', '1');
const mod = await loadBundledModule(distPath);
const chalkInstance = mod.default ?? mod;
const message = chalkInstance.hex('#00ff88')('prebundle-ready');
expect(message).toContain('prebundle-ready');
expect(message).toContain('\u001b[');
rs.unstubAllEnvs();
// rs.unstubAllEnvs();
Comment on lines +22 to +28

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Commenting out rs.stubEnv and rs.unstubAllEnvs without providing an alternative makes this test less reliable. The test still asserts that chalk produces color codes, but without FORCE_COLOR=1, chalk's color output will depend on the environment where the tests are run, which can lead to flaky tests.

If rs.stubEnv is no longer available, you should manually set and restore the environment variable to ensure the test is deterministic. Using a try...finally block is recommended to ensure the environment is cleaned up even if assertions fail.

      const originalForceColor = process.env.FORCE_COLOR;
      try {
        process.env.FORCE_COLOR = '1';
        const mod = await loadBundledModule(distPath);
        const chalkInstance = mod.default ?? mod;
        const message = chalkInstance.hex('#00ff88')('prebundle-ready');
        expect(message).toContain('prebundle-ready');
        expect(message).toContain('\u001b[');
      } finally {
        process.env.FORCE_COLOR = originalForceColor;
      }

},
},
{
Expand Down