Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
processCollection = function (collection, callback) {
if (util.isV1Collection(collection)) {
// @todo: route this via print module to respect silent flags
console.warn('newman: Newman v4 deprecates support for the v1 collection format');
console.warn(' Use the Postman Native app to export collections in the v2 format\n');
return transformer.convert(collection, COLLECTION_TRANSFORMER_OPTION, callback);
}
callback(null, collection);
},
// Errors.terminateWithError("Not a valid POSTMAN globals file");
// }
// }
// Handle Cloud API
if (_.get(options, 'envJson.environment.id')) {
options.envJson = options.envJson.environment;
}
if (_.get(requestJSON, 'collection.info.schema')) {
requestJSON = requestJSON.collection;
}
// Handle collection conversion
if (_.get(requestJSON, 'info.schema')) {
try {
requestJSON = transformer.convert(requestJSON, {
inputVersion: '2.0.0',
outputVersion: '1.0.0'
});
}
catch (e) {
return console.error(e.stack || e);
}
}
if(Math.random()<0.3) {
checking = true;
exec("npm show newman version", {timeout:1500}, function(error, stdout, stderr) {
checking = false;
stdout = stdout.trim();
if (stdout !== Globals.newmanVersion && stdout.length > 0) {
return new Promise((resolve, reject) => {
transformer.convert(collection, upgradeOptions, (error, result) => {
if (error) {
reject(error)
} else {
resolve(result)
}
})
})
}
convert: function(content, callback) {
var options = {
inputVersion: '1.0.0',
outputVersion: '2.0.0'
};
transformer.convert(content, options, function (error, convertedContent) {
if (error) {
callback(error);
return;
}
try {
var collection = new Collection(convertedContent);
var result = LuaGenerator.convert(collection)
callback(null, result);
} catch(error) {
callback(error);
}
});