Skip to content

Commit f802382

Browse files
chore: setup cache input and format files when committing (#426)
Co-authored-by: arturovt <[email protected]>
1 parent 32386f1 commit f802382

File tree

6 files changed

+199
-9
lines changed

6 files changed

+199
-9
lines changed

.husky/pre-commit

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
yarn format:check
5-
yarn lint
4+
yarn lint-staged

lint-staged.config.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default {
2+
'**/*.{ts,js,tsx,jsx,mjs,json,md,mdx,scss,html,yml}': f =>
3+
`npx nx format:write --files=${f.join(',')}`,
4+
'{apps,libs,tools}/**/*.{ts,js}': 'eslint'
5+
};

nx.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"runner": "@nrwl/nx-cloud",
99
"options": {
1010
"cacheableOperations": ["build", "test", "lint"],
11-
"accessToken": "ZDc5YjI3NDItNzg5OS00YWM4LWE4ODItZjAzNjFkOWUwNzE3fHJlYWQtd3JpdGU="
11+
"accessToken": "ZDc5YjI3NDItNzg5OS00YWM4LWE4ODItZjAzNjFkOWUwNzE3fHJlYWQtd3JpdGU=",
12+
"runtimeCacheInputs": ["node -v", "node ./scripts/get-os.js"]
1213
}
1314
}
1415
},

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"build": "nx build",
1313
"watch": "nx build --watch --configuration development",
1414
"test": "nx test",
15-
"format:check": "prettier --config ./.prettierrc --list-different \"{projects,src}/**/*{.ts,.js,.json,.html,.scss}\"",
16-
"format:all": "prettier --config ./.prettierrc --write \"{projects,src}/**/*{.ts,.js,.json,.html,.scss}\"",
15+
"format:write": "nx format:write",
16+
"format:check": "nx format:check",
1717
"build:lib": "nx build @ngu/carousel",
1818
"build:lib:watch": "nx build @ngu/carousel --watch",
1919
"build:app": "nx build",
@@ -70,6 +70,7 @@
7070
"karma-coverage": "2.2.0",
7171
"karma-jasmine": "5.1.0",
7272
"karma-jasmine-html-reporter": "2.0.0",
73+
"lint-staged": "^13.2.0",
7374
"ng-packagr": "15.0.1",
7475
"nx": "15.4.1",
7576
"postcss": "^8.4.5",

scripts/get-os.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// This script is used as a runtime input for the Nx cache.
2+
const os = require('os');
3+
// Things like the version of NodeJS, whether we are running Windows or not, can affect
4+
// the results of the computation but cannot be deduced statically.
5+
console.log(os.type());

0 commit comments

Comments
 (0)