Sha256: e14405de9b36ff21c86bd17255bbe919b659f4182b256f1bb78a69901ec877b9
Contents?: true
Size: 1.04 KB
Versions: 21
Compression:
Stored size: 1.04 KB
Contents
const { promises: fsp } = require('fs'); const { queue } = require('async'); const { glob } = require('glob'); const { parseHTTPServerRequests } = require('./util'); const Model = require('./model'); class SwaggerCommand { constructor(directory) { this.directory = directory; } async execute() { this.count = 0; this.model = new Model(); const q = queue(this.collectAppMap.bind(this), 5); q.pause(); const files = await new Promise((resolve, reject) => { glob(`${this.directory}/**/*.appmap.json`, (err, globFiles) => { if (err) { return reject(err); } return resolve(globFiles); }); }); files.forEach((f) => q.push(f)); await new Promise((resolve, reject) => { q.drain(resolve); q.error(reject); q.resume(); }); return this.model.swagger(); } async collectAppMap(file) { this.count += 1; parseHTTPServerRequests(JSON.parse(await fsp.readFile(file)), (e) => this.model.addRequest(e) ); } } module.exports = SwaggerCommand;
Version data entries
21 entries across 21 versions & 1 rubygems