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

Function checkDistForNodeProtocol

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

* Check if the dist files contain browser-incompatible imports

(packageDir)

Source from the content-addressed store, hash-verified

137 * Check if the dist files contain browser-incompatible imports
138 */
139function checkDistForNodeProtocol(packageDir) {
140 const distDir = join(packageDir, 'dist');
141 if (!existsSync(distDir)) {
142 return { ok: true, issues: [] };
143 }
144
145 const issues = [];
146 const jsFiles = findJsFiles(distDir);
147
148 for (const filePath of jsFiles) {
149 const content = readFileSync(filePath, 'utf8');
150 for (const pattern of BROWSER_INCOMPATIBLE_PATTERNS) {
151 if (pattern.test(content)) {
152 issues.push({
153 file: filePath.replace(ROOT_DIR, ''),
154 pattern: pattern.toString(),
155 });
156 }
157 }
158 }
159
160 return { ok: issues.length === 0, issues };
161}
162
163/**
164 * 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