Skip to content

Commit

Permalink
chore: setup cache input and format files when committing (#426)
Browse files Browse the repository at this point in the history
Co-authored-by: arturovt <arthurandrosovich@gmail.com>
  • Loading branch information
santoshyadavdev and arturovt committed Apr 10, 2023
1 parent 32386f1 commit f802382
Show file tree
Hide file tree
Showing 6 changed files with 199 additions and 9 deletions.
3 changes: 1 addition & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn format:check
yarn lint
yarn lint-staged
5 changes: 5 additions & 0 deletions lint-staged.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
'**/*.{ts,js,tsx,jsx,mjs,json,md,mdx,scss,html,yml}': f =>
`npx nx format:write --files=${f.join(',')}`,
'{apps,libs,tools}/**/*.{ts,js}': 'eslint'
};
3 changes: 2 additions & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"runner": "@nrwl/nx-cloud",
"options": {
"cacheableOperations": ["build", "test", "lint"],
"accessToken": "ZDc5YjI3NDItNzg5OS00YWM4LWE4ODItZjAzNjFkOWUwNzE3fHJlYWQtd3JpdGU="
"accessToken": "ZDc5YjI3NDItNzg5OS00YWM4LWE4ODItZjAzNjFkOWUwNzE3fHJlYWQtd3JpdGU=",
"runtimeCacheInputs": ["node -v", "node ./scripts/get-os.js"]
}
}
},
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"build": "nx build",
"watch": "nx build --watch --configuration development",
"test": "nx test",
"format:check": "prettier --config ./.prettierrc --list-different \"{projects,src}/**/*{.ts,.js,.json,.html,.scss}\"",
"format:all": "prettier --config ./.prettierrc --write \"{projects,src}/**/*{.ts,.js,.json,.html,.scss}\"",
"format:write": "nx format:write",
"format:check": "nx format:check",
"build:lib": "nx build @ngu/carousel",
"build:lib:watch": "nx build @ngu/carousel --watch",
"build:app": "nx build",
Expand Down Expand Up @@ -70,6 +70,7 @@
"karma-coverage": "2.2.0",
"karma-jasmine": "5.1.0",
"karma-jasmine-html-reporter": "2.0.0",
"lint-staged": "^13.2.0",
"ng-packagr": "15.0.1",
"nx": "15.4.1",
"postcss": "^8.4.5",
Expand Down
5 changes: 5 additions & 0 deletions scripts/get-os.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// This script is used as a runtime input for the Nx cache.
const os = require('os');
// Things like the version of NodeJS, whether we are running Windows or not, can affect
// the results of the computation but cannot be deduced statically.
console.log(os.type());
Loading

0 comments on commit f802382

Please sign in to comment.