@@ -17,30 +17,24 @@ const DEPRECATED_SCRIPT_TEMPLATES = Object.freeze([
17
17
18
18
const PLATFORMS = Object . freeze ( [ "android" , "ios" ] ) ;
19
19
20
- function addNpmScripts ( scripts ) {
21
- scripts = scripts || { } ;
22
-
20
+ function addNpmScripts ( scripts = { } ) {
23
21
Object . keys ( SCRIPT_TEMPLATES ) . forEach ( name => {
24
- packageJson = addPlatformScript ( scripts , name , SCRIPT_TEMPLATES [ name ] ) ;
22
+ addPlatformScript ( scripts , name , SCRIPT_TEMPLATES [ name ] ) ;
25
23
} ) ;
26
-
27
- return scripts ;
28
24
}
29
25
30
26
function removeDeprecatedNpmScripts ( scripts ) {
31
27
return removeNpmScripts ( scripts , DEPRECATED_SCRIPT_TEMPLATES ) ;
32
28
}
33
29
34
30
function removeNpmScripts ( scripts , scriptTemplates = Object . keys ( SCRIPT_TEMPLATES ) ) {
35
- scriptTemplates . forEach ( function ( templateName ) {
36
- scripts = removePlatformScripts ( scripts , templateName ) ;
31
+ scriptTemplates . forEach ( templateName => {
32
+ removePlatformScripts ( scripts , templateName ) ;
37
33
} ) ;
38
-
39
- return scripts ;
40
34
}
41
35
42
36
function addPlatformScript ( scripts , nameTemplate , commandTemplate ) {
43
- PLATFORMS . forEach ( function ( platform ) {
37
+ PLATFORMS . forEach ( platform => {
44
38
const name = nameTemplate . replace ( / \[ P L A T F O R M \] / g, platform ) ;
45
39
const command = commandTemplate . replace ( / \[ P L A T F O R M \] / g, platform ) ;
46
40
@@ -49,25 +43,13 @@ function addPlatformScript(scripts, nameTemplate, commandTemplate) {
49
43
scripts [ name ] = command ;
50
44
}
51
45
} ) ;
52
-
53
- return scripts ;
54
46
}
55
47
56
48
function removePlatformScripts ( scripts , nameTemplate ) {
57
- if ( ! scripts || Object . keys ( SCRIPT_TEMPLATES ) . includes ( nameTemplate ) ) {
58
- return scripts ;
59
- }
60
-
61
- PLATFORMS . forEach ( function ( platform ) {
49
+ PLATFORMS . forEach ( platform => {
62
50
const name = nameTemplate . replace ( / \[ P L A T F O R M \] / g, platform ) ;
63
-
64
- if ( scripts [ name ] ) {
65
- console . info ( `Removing script: ${ name } ` ) ;
66
- delete scripts [ name ] ;
67
- }
51
+ delete scripts [ name ] ;
68
52
} ) ;
69
-
70
- return scripts ;
71
53
}
72
54
73
55
module . exports = {
0 commit comments