forked from moqtail/moqtail
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlint-staged.config.js
More file actions
executable file
·41 lines (39 loc) · 1.38 KB
/
Copy pathlint-staged.config.js
File metadata and controls
executable file
·41 lines (39 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* @filename: lint-staged.config.js
* @type {import('lint-staged').Configuration}
*/
export default {
'(apps|libs)/**/*.{rs,toml}': (files) => {
const projects = files.reduce((acc, file) => {
const match = file.match(/^((apps|libs)\/[^/]+)/)
if (match) {
const project = match[1]
if (!acc.includes(project)) acc.push(project)
}
return acc
}, [])
return projects.flatMap((project) => {
const manifestPathArg = `--manifest-path=${project}/Cargo.toml`
const all = `--all-targets --all-features`
return [
// Run cargo clippy once for every changed project
`cargo clippy ${manifestPathArg} ${all} --fix --allow-dirty -- -D warnings`,
// Run cargo fmt once for every changed project
`cargo fmt ${manifestPathArg}`,
// Run cargo build once for every changed project
`cargo build ${manifestPathArg} ${all}`,
// Run cargo check once for every changed project
`cargo check ${manifestPathArg} ${all}`,
// Run cargo test once for every changed project
`cargo test ${manifestPathArg} ${all}`,
]
})
},
// Run build/test for all changed projects (at once)
'(apps|libs)/**/*.ts*': () => [
'npm run build', // The order of builds matter
'npm run test',
],
// Run prettier for rest of the files
'*': ['prettier --ignore-unknown --write'],
}