@@ -75,9 +75,13 @@ const isRunIf = is.schema({
75
75
env : is . maybe . object
76
76
} )
77
77
78
- function isPlatformAllowed ( platform ) {
78
+ function isPlatformAllowed ( platform , osPlatform = os . platform ( ) ) {
79
+ if ( ! platform ) {
80
+ return true
81
+ }
82
+ debug ( 'checking platform, allowed platform is' , platform )
79
83
la ( is . unemptyString ( platform ) , 'invalid allowed platform' , platform )
80
- return platform === '*' || platform . indexOf ( os . platform ( ) ) !== - 1
84
+ return platform === '*' || platform . indexOf ( osPlatform ) !== - 1
81
85
}
82
86
83
87
function getCommand ( args ) {
@@ -97,25 +101,33 @@ function getCommand (args) {
97
101
function runIf ( command , json ) {
98
102
la ( is . unemptyString ( command ) , 'missing command to run' , command )
99
103
la ( isRunIf ( json ) , 'invalid runIf json' , json )
100
- return execa . shell ( command , { env : json . env } ) . then ( prop ( 'stdout' ) )
104
+
105
+ if ( ! isPlatformAllowed ( json . platform , os . platform ( ) ) ) {
106
+ console . log ( 'Required platform: %s' , json . platform )
107
+ console . log ( 'Current platform: %s' , os . platform ( ) )
108
+ console . log ( 'skipping command' )
109
+ return Promise . resolve ( )
110
+ }
111
+
112
+ const options = {
113
+ env : json . env ,
114
+ stdio : 'inherit'
115
+ }
116
+ return execa . shell ( command , options ) . then ( prop ( 'stdout' ) )
101
117
}
102
118
103
119
function npmInstall ( json ) {
104
120
if ( ! json ) {
105
121
debug ( 'missing json for npm install' )
106
- return
122
+ return Promise . resolve ( )
107
123
}
108
124
la ( isNpmInstall ( json ) , 'invalid JSON to install format' , json )
109
125
110
- if ( json . platform ) {
111
- debug ( 'checking platform, expecting' , json . platform )
112
- la ( is . unemptyString ( json . platform ) , 'invalid json platform' , json . platform )
113
- if ( ! isPlatformAllowed ( json . platform ) ) {
114
- console . log ( 'Required platform: %s' , json . platform )
115
- console . log ( 'Current platform: %s' , os . platform ( ) )
116
- console . log ( 'skipping install' )
117
- return
118
- }
126
+ if ( ! isPlatformAllowed ( json . platform , os . platform ( ) ) ) {
127
+ console . log ( 'Required platform: %s' , json . platform )
128
+ console . log ( 'Current platform: %s' , os . platform ( ) )
129
+ console . log ( 'skipping install' )
130
+ return Promise . resolve ( )
119
131
}
120
132
121
133
const env = json . env || { }
0 commit comments