chore: Fix lefthook config for windows (#22676)

Co-authored-by: RomanDavydchuk <roman.davydchuk@n8n.io>
This commit is contained in:
yehorkardash 2025-12-08 06:53:13 +01:00 committed by GitHub
parent f72bbaf088
commit 85d9465ad9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 34 additions and 12 deletions

View File

@ -28,18 +28,7 @@ pre-commit:
- rebase
workspace_deps_check:
glob: '**/package.json'
run: |
if grep -l '"workspace:\^"' {staged_files} 2>/dev/null; then
echo ""
echo "ERROR: Found 'workspace:^' in package.json files."
echo ""
echo "Use 'workspace:*' instead to pin exact versions."
echo "Using 'workspace:^' causes npm to resolve semver ranges when users"
echo "install from npm, which can lead to version mismatches between"
echo "@n8n/* packages and break n8n startup."
echo ""
exit 1
fi
run: node scripts/check-workspace-deps.mjs {staged_files}
skip:
- merge
- rebase

View File

@ -0,0 +1,33 @@
#!/usr/bin/env node
import { readFileSync } from 'node:fs';
import { existsSync } from 'node:fs';
const isPackageJson = (file) => file.endsWith('package.json');
const files = process.argv.slice(2).filter((file) => file && isPackageJson(file) && existsSync(file));
let foundError = false;
for (const file of files) {
try {
const content = readFileSync(file, 'utf8');
if (content.includes('"workspace:^"')) {
if (!foundError) {
console.log('');
console.log("ERROR: Found 'workspace:^' in package.json files.");
console.log('');
console.log("Use 'workspace:*' instead to pin exact versions.");
console.log("Using 'workspace:^' causes npm to resolve semver ranges when users");
console.log("install from npm, which can lead to version mismatches between");
console.log("@n8n/* packages and break n8n startup.");
console.log('');
}
foundError = true;
}
} catch (error) {
// Ignore read errors for individual files
}
}
if (foundError) {
process.exit(1);
}