Skip to content

Commit

Permalink
Merge pull request #83 from vishrutshah/oad-v0.1.5
Browse files Browse the repository at this point in the history
Update sequence to look for autorest in different cases
  • Loading branch information
vishrutshah authored Jul 20, 2017
2 parents 535f741 + 5eb247d commit ccc3ad2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ exports.log = require('./lib/util/logging');
exports.compare = validate.compare;

// Classes
exports.OpenApiDiff = require('./lib/validators/OpenApiDiff');
exports.OpenApiDiff = require('./lib/validators/openApiDiff');

// Constants
exports.Constants = require('./lib/util/constants');
15 changes: 13 additions & 2 deletions lib/validators/openApiDiff.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,18 @@ class OpenApiDiff {
autoRestPath() {
log.silly(`autoRestPath is being called`);

return path.join(__dirname, "..", "..", "node_modules", "autorest", "app.js");
// When oad is installed globally
let result = path.join(__dirname, "..", "..", "node_modules", "autorest", "app.js");
if (fs.existsSync(result))
return `node ${result}`;

// When oad is installed locally
result = path.join(__dirname, "..", "..", "..", "autorest", "app.js");
if (fs.existsSync(result))
return `node ${result}`;

// Assume that autorest is in the path
return 'autorest';
}

/**
Expand Down Expand Up @@ -144,7 +155,7 @@ class OpenApiDiff {

let outputFolder = os.tmpdir();
let outputFilePath = path.join(outputFolder, `${outputFileName}.json`);
let autoRestCmd = `node ${self.autoRestPath()} --input-file=${swaggerPath} --output-artifact=swagger-document.json --output-file=${outputFileName} --output-folder=${outputFolder}`;
let autoRestCmd = `${self.autoRestPath()} --input-file=${swaggerPath} --output-artifact=swagger-document.json --output-file=${outputFileName} --output-folder=${outputFolder}`;

log.debug(`Executing: "${autoRestCmd}"`);

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oad",
"version": "0.1.4",
"version": "0.1.5",
"author": {
"name": "Microsoft Corporation",
"email": "[email protected]",
Expand Down

0 comments on commit ccc3ad2

Please sign in to comment.