File tree Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -187,16 +187,34 @@ func RunDirectly(cmd []string) error {
187
187
}
188
188
189
189
func Run (cmd []string ) error {
190
- if len (cmd ) == 0 {
191
- return errors .New ("commands is required" )
192
- }
193
-
194
190
cwd , err := os .Getwd ()
195
191
196
192
if err != nil {
197
193
return errors .WithStack (err )
198
194
}
199
195
196
+ if len (cmd ) == 0 {
197
+ packageJSONPath := util .LoopUpFile (cwd , "package.json" )
198
+
199
+ if packageJSONPath != nil {
200
+ util .Debug ("Use node constraint from %s\n " , * packageJSONPath )
201
+
202
+ constraint , err := node .GetConstraintFromPackageJSON (* packageJSONPath )
203
+
204
+ if err != nil {
205
+ return err
206
+ }
207
+
208
+ if constraint != nil {
209
+ util .Debug ("Use node constraint: %s\n " , * constraint )
210
+ return Use (constraint )
211
+ }
212
+
213
+ } else {
214
+ return errors .New ("commands is required" )
215
+ }
216
+ }
217
+
200
218
packageJSONPath := util .LoopUpFile (cwd , "package.json" )
201
219
202
220
// If the package.json file is found, then use the node constraint in the package.json to run the command
You can’t perform that action at this time.
0 commit comments