1
1
import { createLocalConfigManager , jsState } from "src/utils/config" ;
2
2
import { addFileToRoot , addJsonFileToRoot } from "src/utils/fs" ;
3
- import { installDevelopmentDependencies } from "src/utils/npm"
3
+ import { addScripts , installDevelopmentDependencies } from "src/utils/npm"
4
4
5
5
const defaultConfig = {
6
6
config : {
@@ -18,18 +18,24 @@ const defaultConfig = {
18
18
}
19
19
]
20
20
} ,
21
- ignore : [ 'dist' , 'node_modules' , 'public' , '.husky' , 'package-lock.json' ]
21
+ ignore : [ 'dist' , 'node_modules' , 'public' , '.husky' , 'package-lock.json' ] ,
22
+ scripts : [
23
+ { name : 'format' , script : 'prettier' } ,
24
+ { name : 'format:fix' , script : 'prettier --write .' }
25
+ ]
22
26
}
23
27
24
28
const [ getConfig ] = createLocalConfigManager ( jsState , {
25
29
default : defaultConfig
26
30
} ) ;
27
31
28
32
export const prettier = async ( ) => {
29
- const { config, ignore } = getConfig ( ) ;
33
+ const { config, ignore, scripts } = getConfig ( ) ;
30
34
31
35
await installDevelopmentDependencies ( 'prettier' ) ;
32
36
await addJsonFileToRoot ( '.prettierrc' , config ) ;
33
37
34
38
await addFileToRoot ( '.prettierignore' , ignore . join ( '\n' ) ) ;
39
+
40
+ await addScripts ( ...scripts ) ;
35
41
}
0 commit comments