I'm trying to put a script together that i can use in my CI build that will work as a linter for my Typescript Mono-repo project.
What I'm trying to accomplish is see if there are any .js files within the project/package repos, but avoid node_modules folders where ever they are located and also the common folder and all its subdirectories and files.
The file structure is like this
project/
├── apps/
│ ├── app1
├── common/
│ ├── folder1
│ ├── folder1
│ ├── etc
├── lib/
│ ├── lib1
├── services/
│ ├── service1
With the sub-directories of services,lib,apps all being npm projects.
Currently some of the different attempts I've tried include:
find . \( ! -name node_modules \) -o \( ! -path common -prune \) -name "*.js" -print
But it doesn't seem to return anything even when I create dummy .js files in /project or any of the other whitelisted folders.
This attempt seems to be the closest as it prints out the test files, but it also finds files within common, but it should be blacklisted.
find . -type d \( -path common -o -name node_modules \) -prune -false -o -name '*.js'
The output of that run:
./test.js
./common/temp/pnpmfile.js
./common/temp/pnpm-store/2/registry.npmjs.org/ipaddr.js
./common/config/rush/pnpmfile.js
./common/scripts/install-run.js
./common/scripts/install-run-rushx.js
./common/scripts/install-run-rush.js
./services/test.js
The overall goal I want from this script is to, exit 0 if no .js files are found within the whitelisted directories or return exit 1 if a .js file is found outside of the blacklisted directories.
I'm pretty new and inexperienced with shell commands, so any help would be appreciated Thank you in advance!