-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.ts
69 lines (53 loc) · 1.67 KB
/
run.ts
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import * as fs from 'fs';
var getpath = require("path");
import { getSwaggerData } from './pack/getFullCollection';
import { verifyOutputPath } from './pack/utility/utility';
function runProject(inputPath,outputPath){
return new Promise(function (resolve, reject) {
fs.readFile(inputPath,(error,data:any)=>{
try{
//Checking that path is exist or not
if(fs.existsSync(inputPath)){
data=JSON.parse(data)
// ** handling extra Array
let input:any
input=data.item[0].item
if(!input){
input=data
}
else{
input=data.item[0]
input.info=data.info
}
let yamlFilePath=getpath.resolve("../")+"/swagger-tool-output.yaml";
//checking path for output yaml file
if(verifyOutputPath(outputPath)){
yamlFilePath=outputPath;
}
// ***
var writeData=getSwaggerData(input)
//writing the file
fs.writeFile(yamlFilePath, writeData, (data) => {
console.log("\n\n******* done *********\n");
console.log(`Output Path ${yamlFilePath}\n\n`);
resolve({yamlFilePath,writeData});
// console.log("If response is not in your postman collection an example response will be added automatically\n");
console.log("**************************************************************\n\n");
});
}
else
console.log("⛔⛔⛔ ERROR ⛔ ⛔⛔ \nCollection path is incorrect\n\n");
}catch(e){
//Printing the error
console.log("\n\n ⛔⛔⛔ ERROR ⛔ ⛔⛔ \n"+e);
console.log("Collection is not correct\n\n");
reject("Collection is not correct\n\n");
}
})
})
}
function fun(){
console.log("Simple logging");
}
// runProject(inputPath,outputPath);
export {runProject,fun}