-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
25 lines (21 loc) · 822 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const fs = require('fs') // needed to read JSON file from disk
const Collection = require('postman-collection').Collection;
const beautify = require('beautify');
// Load a collection to memory from a JSON file on disk (say, sample-collection.json)
var collection = new Collection(JSON.parse(fs.readFileSync(process.argv[2]).toString()))
//console.log(collection)
var routes = [];
collection.forEachItem((a,b,c)=>{
try {
routes.push({method:a.request.method, route:a.request.url.getPath({unresolved:true})})
console.log(a.request.method+addSpaces(8 - a.request.method.length )+a.request.url.getPath({unresolved:true}))
} catch (e) { }
})
function addSpaces(num) {
var spaces = "";
for (var i = 0; i < num; i++) {
spaces += ' ';
}
return spaces
}
console.log(JSON.stringify(routes, null, 4))