Skip to content

Commit

Permalink
added ability to transform collections
Browse files Browse the repository at this point in the history
  • Loading branch information
Aniket Panse committed Feb 24, 2016
1 parent 604cb51 commit a02627e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"lodash": "^3.3.0",
"mkdirp": "^0.5.0",
"node-uuid": "1.4.1",
"postman-collection-transformer": "^1.4.1",
"postman_validator": "0.0.4",
"request": "2.64.0",
"sugar": "1.3.9",
Expand Down
26 changes: 22 additions & 4 deletions src/Newman.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ var jsface = require("jsface"),
Options = require('./utilities/Options'),
log = require('./utilities/Logger'),
fs = require('fs'),
_ = require('lodash'),
transformer = require('postman-collection-transformer'),
exec = require('child_process').exec;

/**
Expand All @@ -26,7 +28,8 @@ var Newman = jsface.Class([Options, EventEmitter], {
*/
execute: function(requestJSON, options, callback) {
var checking = false,
onChecked = null;
onChecked = null,
self = this;
// var collectionParseError = Validator.validateJSON('c',requestJSON);
// if(!collectionParseError.status) {
// Errors.terminateWithError("Not a valid POSTMAN collection");
Expand Down Expand Up @@ -99,9 +102,24 @@ var Newman = jsface.Class([Options, EventEmitter], {
}

// setup the iteration runner with requestJSON passed and options
this.iterationRunner = new IterationRunner(requestJSON, this.getOptions());

this.iterationRunner.execute();
if (_.get(requestJSON, 'info.schema')) {
// Need to convert the V2 collection to V1 and then run it.
transformer.convert(requestJSON, {
inputVersion: '2.0.0',
outputVersion: '1.0.0'
}, function (err, result) {
if (err) {
console.error(err.stack || err);
}
console.log('converted the collection, now running');
self.iterationRunner = new IterationRunner(result, self.getOptions());
self.iterationRunner.execute();
});
}
else {
this.iterationRunner = new IterationRunner(requestJSON, this.getOptions());
this.iterationRunner.execute();
}
}
});

Expand Down

0 comments on commit a02627e

Please sign in to comment.