@@ -100,7 +100,18 @@ class OpenApiDiff {
100
100
autoRestPath ( ) {
101
101
log . silly ( `autoRestPath is being called` ) ;
102
102
103
- return path . join ( __dirname , ".." , ".." , "node_modules" , "autorest" , "app.js" ) ;
103
+ // When oad is installed globally
104
+ let result = path . join ( __dirname , ".." , ".." , "node_modules" , "autorest" , "app.js" ) ;
105
+ if ( fs . existsSync ( result ) )
106
+ return `node ${ result } ` ;
107
+
108
+ // When oad is installed locally
109
+ result = path . join ( __dirname , ".." , ".." , ".." , "autorest" , "app.js" ) ;
110
+ if ( fs . existsSync ( result ) )
111
+ return `node ${ result } ` ;
112
+
113
+ // Assume that autorest is in the path
114
+ return 'autorest' ;
104
115
}
105
116
106
117
/**
@@ -144,7 +155,7 @@ class OpenApiDiff {
144
155
145
156
let outputFolder = os . tmpdir ( ) ;
146
157
let outputFilePath = path . join ( outputFolder , `${ outputFileName } .json` ) ;
147
- let autoRestCmd = `node ${ self . autoRestPath ( ) } --input-file=${ swaggerPath } --output-artifact=swagger-document.json --output-file=${ outputFileName } --output-folder=${ outputFolder } ` ;
158
+ let autoRestCmd = `${ self . autoRestPath ( ) } --input-file=${ swaggerPath } --output-artifact=swagger-document.json --output-file=${ outputFileName } --output-folder=${ outputFolder } ` ;
148
159
149
160
log . debug ( `Executing: "${ autoRestCmd } "` ) ;
150
161
0 commit comments