mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-19 21:46:49 +00:00
724c88c201
A mechanical prettier --write over server/src, server/tests, server/scripts and shared/src with the workspaces' .prettierrc; nothing but layout and import order changes, and every file keeps the same set of imports. shared is formatted throughout and its format baseline is empty. The server baseline keeps the 35 files that Prettier would grow past their lint:size limit (they need a split first, which is not a formatting change), and the generated entity files stay as their generator writes them.
38 lines
1.5 KiB
TypeScript
38 lines
1.5 KiB
TypeScript
/**
|
|
* Native-binary scan (#plugins, M4): .node / binding.gyp / prebuilds are
|
|
* forbidden; symlinks are never followed.
|
|
*/
|
|
import { scanForNativeBinaries } from '../../../src/nest/plugins/install/native-scan';
|
|
|
|
import fs from 'node:fs';
|
|
import os from 'node:os';
|
|
import path from 'node:path';
|
|
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
|
|
let dir: string;
|
|
beforeEach(() => {
|
|
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'nscan-'));
|
|
});
|
|
afterEach(() => {
|
|
fs.rmSync(dir, { recursive: true, force: true });
|
|
});
|
|
|
|
describe('scanForNativeBinaries', () => {
|
|
it('is clean for a plain JS plugin', () => {
|
|
fs.mkdirSync(path.join(dir, 'server'), { recursive: true });
|
|
fs.writeFileSync(path.join(dir, 'server', 'index.js'), 'module.exports = {}');
|
|
expect(scanForNativeBinaries(dir)).toEqual([]);
|
|
});
|
|
|
|
it('flags .node binaries, binding.gyp and prebuilds/', () => {
|
|
fs.mkdirSync(path.join(dir, 'node_modules', 'sharp', 'prebuilds'), { recursive: true });
|
|
fs.writeFileSync(path.join(dir, 'node_modules', 'sharp', 'sharp.node'), '\0');
|
|
fs.writeFileSync(path.join(dir, 'node_modules', 'sharp', 'binding.gyp'), '{}');
|
|
fs.writeFileSync(path.join(dir, 'node_modules', 'sharp', 'prebuilds', 'x.txt'), 'x');
|
|
const hits = scanForNativeBinaries(dir);
|
|
expect(hits.some((h) => h.endsWith('sharp.node'))).toBe(true);
|
|
expect(hits.some((h) => h.endsWith('binding.gyp'))).toBe(true);
|
|
expect(hits.some((h) => h.includes('prebuilds'))).toBe(true);
|
|
});
|
|
});
|