regressionbot 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +11 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -168,6 +168,12 @@ async function checkStatus(jobId) {
|
|
|
168
168
|
const status = await job.getStatus();
|
|
169
169
|
console.log(JSON.stringify(status, null, 2));
|
|
170
170
|
}
|
|
171
|
+
function sanitizeFilename(name) {
|
|
172
|
+
if (!name)
|
|
173
|
+
return 'unknown';
|
|
174
|
+
// Allow alphanumeric, underscore, hyphen, space.
|
|
175
|
+
return name.replace(/[^a-zA-Z0-9_\- ]/g, '_');
|
|
176
|
+
}
|
|
171
177
|
async function showSummary(jobId, options = {}) {
|
|
172
178
|
const job = sdk.job(jobId);
|
|
173
179
|
const summary = await job.getSummary();
|
|
@@ -186,7 +192,8 @@ Errors: ${summary.errorCount}
|
|
|
186
192
|
if (options.download) {
|
|
187
193
|
const fs = require('fs');
|
|
188
194
|
const path = require('path');
|
|
189
|
-
const
|
|
195
|
+
const safeJobId = sanitizeFilename(jobId);
|
|
196
|
+
const dir = path.join(process.cwd(), 'regressions', safeJobId);
|
|
190
197
|
if (!fs.existsSync(dir))
|
|
191
198
|
fs.mkdirSync(dir, { recursive: true });
|
|
192
199
|
const res = await fetch(summary.collageUrl);
|
|
@@ -204,7 +211,9 @@ Errors: ${summary.errorCount}
|
|
|
204
211
|
if (options.download) {
|
|
205
212
|
const fs = require('fs');
|
|
206
213
|
const path = require('path');
|
|
207
|
-
const
|
|
214
|
+
const safeJobId = sanitizeFilename(jobId);
|
|
215
|
+
const safeVariantName = sanitizeFilename(r.variantName);
|
|
216
|
+
const dir = path.join(process.cwd(), 'regressions', safeJobId, safeVariantName);
|
|
208
217
|
if (!fs.existsSync(dir))
|
|
209
218
|
fs.mkdirSync(dir, { recursive: true });
|
|
210
219
|
const download = async (url, name) => {
|
package/package.json
CHANGED