mirror of
https://github.com/n8n-io/n8n.git
synced 2026-05-12 16:10:30 +02:00
chore: Fix lefthook config for windows (#22676)
Co-authored-by: RomanDavydchuk <roman.davydchuk@n8n.io>
This commit is contained in:
parent
f72bbaf088
commit
85d9465ad9
13
lefthook.yml
13
lefthook.yml
|
|
@ -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
|
||||
|
|
|
|||
33
scripts/check-workspace-deps.mjs
Normal file
33
scripts/check-workspace-deps.mjs
Normal 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);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user