forked from schwabyio/xrun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xrun.js
executable file
·103 lines (82 loc) · 2.93 KB
/
xrun.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
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env node
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// //
// xrun.js - A more awesome way to run Postman tests from the command line. //
// //
// Created by: schwaby.io //
// //
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
'use strict'
try {
const xRunLib = require('./lib/xrun-lib')
const xRun = new xRunLib()
const programCommand = process.argv[2] || ''
if (! programCommand) {
(async () => {
try {
const settingsPath = await xRun.initializeSettingsPath()
const settings = await xRun.getSettings(settingsPath)
const usage = await xRun.getUsage()
console.log(usage)
process.exit(0)
} catch (errMsg) {
console.log(errMsg)
process.exit(1)
}
})()
} else {
if (programCommand === 'g' || programCommand === 'get') {
(async () => {
try {
const settingsPath = await xRun.initializeSettingsPath()
const settings = await xRun.getSettings(settingsPath)
const collectionInfoString = await xRun.getPostmanTests(settings)
console.log(collectionInfoString)
process.exit(0)
} catch (errMsg) {
console.log(errMsg)
process.exit(1)
}
})()
} else if (programCommand === 'a' || programCommand === 'all') {
(async () => {
try {
const settingsPath = await xRun.initializeSettingsPath()
const settings = await xRun.getSettings(settingsPath)
const testFinalResult = await xRun.runAllPostmanTests(settings)
if (testFinalResult === 'PASSED') {
process.exit(0)
} else {
process.exit(1)
}
} catch (errMsg) {
console.log(errMsg)
process.exit(1)
}
})()
} else {
(async () => {
try {
const settingsPath = await xRun.initializeSettingsPath()
const settings = await xRun.getSettings(settingsPath)
//Set collectionCSVList
const collectionCSVList = programCommand
const testFinalResult = await xRun.runCSVPostmanTests(settings, collectionCSVList)
if (testFinalResult === 'PASSED') {
process.exit(0)
} else {
process.exit(1)
}
} catch (errMsg) {
console.log(errMsg)
process.exit(1)
}
})()
}
}
} catch (error) {
console.log(`${error.message}`)
process.exit(1)
}