@@ -100,7 +100,18 @@ class OpenApiDiff {
100100 autoRestPath ( ) {
101101 log . silly ( `autoRestPath is being called` ) ;
102102
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' ;
104115 }
105116
106117 /**
@@ -144,7 +155,7 @@ class OpenApiDiff {
144155
145156 let outputFolder = os . tmpdir ( ) ;
146157 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 } ` ;
148159
149160 log . debug ( `Executing: "${ autoRestCmd } "` ) ;
150161
0 commit comments