Skip to content

Commit 8556fe6

Browse files
committed
fix non-unix chmod
1 parent cc03ad8 commit 8556fe6

File tree

1 file changed

+11
-6
lines changed
  • tests/rspack-test/configCases/rslib/hashbang-and-chmod

1 file changed

+11
-6
lines changed

tests/rspack-test/configCases/rslib/hashbang-and-chmod/test.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,16 @@ testCases.forEach(({ name, file }) => {
1515
expect(content.startsWith('#!/usr/bin/env node\n')).toBe(true);
1616
});
1717

18-
it (`should set executable permissions (0o755) for files with hashbang (${name})`, () => {
19-
const filePath = path.resolve(__dirname, file);
20-
const stats = fs.statSync(filePath);
21-
const permissions = stats.mode & 0o777;
18+
// File permissions (chmod) are only supported on Unix-like systems (Linux, macOS, BSD, etc.).
19+
// Skip on Windows and WASM environments where Unix permissions are not supported.
20+
const onUnix = process.platform !== 'win32' && !process.env.WASM;
21+
if (onUnix) {
22+
it(`should set executable permissions (0o755) for files with hashbang (${name})`, () => {
23+
const filePath = path.resolve(__dirname, file);
24+
const stats = fs.statSync(filePath);
25+
const permissions = stats.mode & 0o777;
2226

23-
expect(permissions).toBe(0o755);
24-
});
27+
expect(permissions).toBe(0o755);
28+
});
29+
}
2530
});

0 commit comments

Comments
 (0)