MCPcopy Create free account
hub / github.com/decaporg/decap-cms / checkDistForNodeProtocol

Function checkDistForNodeProtocol

scripts/test-package-integrity.mjs:59–81  ·  view source on GitHub ↗

* Check if the dist files contain browser-incompatible imports

(packageDir)

Source from the content-addressed store, hash-verified

57 * Check if the dist files contain browser-incompatible imports
58 */
59function checkDistForNodeProtocol(packageDir) {
60 const distDir = join(packageDir, 'dist');
61 if (!existsSync(distDir)) {
62 return { ok: true, issues: [] };
63 }
64
65 const issues = [];
66 const jsFiles = findJsFiles(distDir);
67
68 for (const filePath of jsFiles) {
69 const content = readFileSync(filePath, 'utf8');
70 for (const pattern of BROWSER_INCOMPATIBLE_PATTERNS) {
71 if (pattern.test(content)) {
72 issues.push({
73 file: filePath.replace(ROOT_DIR, ''),
74 pattern: pattern.toString(),
75 });
76 }
77 }
78 }
79
80 return { ok: issues.length === 0, issues };
81}
82
83/**
84 * Test that a package can be packed without errors

Callers 1

testBrowserCompatibilityFunction · 0.85

Calls 3

findJsFilesFunction · 0.85
replaceMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected