@@ -28,28 +28,17 @@ let removeRescriptCore = (config: Dict.t<JSON.t>) => {
28
28
}
29
29
}
30
30
31
- let modernizeConfigurationFields = (config : Dict .t <JSON .t >) => {
32
- // Rename "bs-dependencies" to "dependencies"
33
- switch config -> Dict .get ("bs-dependencies" ) {
34
- | Some (dependencies ) =>
35
- config -> Dict .set ("dependencies" , dependencies )
36
- config -> Dict .delete ("bs-dependencies" )
37
- | _ => ()
38
- }
39
-
40
- // Rename "bs-dev-dependencies" to "devDependencies"
41
- switch config -> Dict .get ("bs-dev-dependencies" ) {
42
- | Some (devDependencies ) =>
43
- config -> Dict .set ("dev-dependencies" , devDependencies )
44
- config -> Dict .delete ("bs-dev-dependencies" )
31
+ let renameConfigKey = (config : Dict .t <JSON .t >, ~from , ~to ) => {
32
+ switch config -> Dict .get (from ) {
33
+ | Some (value ) =>
34
+ config -> Dict .set (to , value )
35
+ config -> Dict .delete (from )
45
36
| _ => ()
46
37
}
38
+ }
47
39
48
- // Rename "bsc-flags" to "compiler-flags"
49
- switch config -> Dict .get ("bsc-flags" ) {
50
- | Some (compilerFlags ) =>
51
- config -> Dict .set ("compiler-flags" , compilerFlags )
52
- config -> Dict .delete ("bsc-flags" )
53
- | _ => ()
54
- }
40
+ let modernizeConfigurationFields = (config : Dict .t <JSON .t >) => {
41
+ renameConfigKey (config , ~from = "bs-dependencies" , ~to = "dependencies" )
42
+ renameConfigKey (config , ~from = "bs-dev-dependencies" , ~to = "dev-dependencies" )
43
+ renameConfigKey (config , ~from = "bsc-flags" , ~to = "compiler-flags" )
55
44
}
0 commit comments