Skip to content

Commit ccc3ad2

Browse files
authoredJul 20, 2017
Merge pull request #83 from vishrutshah/oad-v0.1.5
Update sequence to look for autorest in different cases
2 parents 535f741 + 5eb247d commit ccc3ad2

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed
 

‎index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ exports.log = require('./lib/util/logging');
1111
exports.compare = validate.compare;
1212

1313
// Classes
14-
exports.OpenApiDiff = require('./lib/validators/OpenApiDiff');
14+
exports.OpenApiDiff = require('./lib/validators/openApiDiff');
1515

1616
// Constants
1717
exports.Constants = require('./lib/util/constants');

‎lib/validators/openApiDiff.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -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

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "oad",
3-
"version": "0.1.4",
3+
"version": "0.1.5",
44
"author": {
55
"name": "Microsoft Corporation",
66
"email": "azsdkteam@microsoft.com",

0 commit comments

Comments
 (0)
Please sign in to comment.