Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: resolve husky pre-push and pre-commit errors (#10365)
## Summary Resolve a few errors in our `pre-commit` and `pre-push` hooks: 1. The `support/updateStylelintCustomSassFunctions.ts` script was trying to open scss files in the root directory. ```text Error reading file: /home/jamin/dev/work/calcite-design-system/dev/ComponentWithSass.scss Error: ENOENT: no such file or directory, open '/home/jamin/dev/work/calcite-design-system/dev/ComponentWithSass.scss' at Object.readFileSync (node:fs:448:20) at <anonymous> (/home/jamin/dev/work/calcite-design-system/dev/support/updateStylelintCustomSassFunctions.ts:37:24) at Array.forEach (<anonymous>) at sassFiles (/home/jamin/dev/work/calcite-design-system/dev/support/updateStylelintCustomSassFunctions.ts:35:11) at Object.<anonymous> (/home/jamin/dev/work/calcite-design-system/dev/support/updateStylelintCustomSassFunctions.ts:63:1) at Module._compile (node:internal/modules/cjs/loader:1358:14) at Object.transformer (/home/jamin/dev/work/calcite-design-system/dev/node_modules/tsx/dist/register-C1urN2EO.cjs:2:1122) at Module.load (node:internal/modules/cjs/loader:1208:32) at Module._load (node:internal/modules/cjs/loader:1024:12) at cjsLoader (node:internal/modules/esm/translators:348:17) { errno: -2, code: 'ENOENT', syscall: 'open', path: '/home/jamin/dev/work/calcite-design-system/dev/ComponentWithSass.scss' } ``` 2. The stylelint config file extension was incorrect. ```text Stylelint configuration updated successfully fatal: pathspec 'packages/calcite-components/.stylelintrc.json' did not match any files ``` 3. The `pre-push` hook was only protecting `main` when it should protect `rc` and `dev` too. 4. [Husky requires scripts to be POSIX compliant](https://typicode.github.io/husky/how-to.html#bash), which means we can't use bash features. - Replace the `read` prompt's `-p` and `-n` flags with a printf and case statement - Replace double bracket conditionals used for pattern matching with `grep -qE` in the `pre-commit` hook ```text .husky/pre-commit: 40: [[: not found .husky/pre-commit: 16: [[: not found ```
- Loading branch information