Comparing version 0.0.2 to 0.0.3
45
index.js
@@ -49,2 +49,13 @@ #!/usr/bin/env node | ||
const logBreachError = async breach => { | ||
console.error( | ||
`${RED_X} ${chalk.red.bold(breach.name)}: ${breach.result} (expected ${ | ||
breach.quest.baseline | ||
} or ${breach.quest.minimize ? "less" : "more"})` | ||
); | ||
if (breach.quest.description) { | ||
console.error("", breach.quest.description); | ||
} | ||
}; | ||
async function postMetrics(apiKey, successes, breaches) { | ||
@@ -151,7 +162,19 @@ let response; | ||
} | ||
if (failed || !questIsInGuardMode(quest)) { | ||
logQuestResult(name, quest, result, Date.now() - questStart.getTime()); | ||
if (failed) { | ||
// policy failed | ||
logBreachError(_.last(breaches)); | ||
} else { | ||
// policy is okay | ||
if (!questIsInGuardMode(quest)) { | ||
logQuestResult( | ||
name, | ||
quest, | ||
result, | ||
Date.now() - questStart.getTime() | ||
); | ||
} | ||
} | ||
}) | ||
); | ||
console.log("\n"); | ||
return { | ||
@@ -173,3 +196,2 @@ successes, | ||
if (breaches.length) { | ||
breaches.map(logBreachError); | ||
logCheckFailedError(); | ||
@@ -187,3 +209,2 @@ process.exitCode = 1; | ||
if (breaches.length) { | ||
breaches.map(logBreachError); | ||
logCheckFailedError(); | ||
@@ -494,14 +515,2 @@ } | ||
const logBreachError = async breach => { | ||
console.error( | ||
"\n", | ||
`${RED_X} ${chalk.red.bold(breach.name)}: ${breach.result} (expected ${ | ||
breach.quest.baseline | ||
} or ${breach.quest.minimize ? "less" : "more"})` | ||
); | ||
if (breach.quest.description) { | ||
console.error("", breach.quest.description, "\n\n"); | ||
} | ||
}; | ||
const actionCinch = async questName => { | ||
@@ -530,6 +539,4 @@ ensureConfig(); | ||
if (results.breaches.length > 0) { | ||
const [firstBreach] = results.breaches; | ||
logBreachError(firstBreach); | ||
console.error( | ||
"Cannot cinch a metric that doesn't even meet the baseline. \n" | ||
chalk.bold("Cannot cinch a metric that doesn't even meet the baseline. \n") | ||
); | ||
@@ -536,0 +543,0 @@ process.exitCode = 1; |
{ | ||
"name": "diffjam", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "cli for diffjam.com", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
55008
825