-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix rules; use three dot actions; fix fail state
- Loading branch information
Showing
4 changed files
with
42 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ import { walkTextFiles } from "../../walkTextFiles.ts"; | |
import * as colors from "https://deno.land/[email protected]/fmt/colors.ts"; | ||
import { relative } from "https://deno.land/[email protected]/path/mod.ts"; | ||
import { readConfig } from "../../config.ts"; | ||
import { Change, getChangesAsFiles, getChangesAsHunks } from "../../git.ts"; | ||
import { Change, getChangesAsHunks } from "../../git.ts"; | ||
import * as frontmatter from "https://deno.land/x/[email protected]/mod.ts"; | ||
import { globToRegExp } from "https://deno.land/[email protected]/path/glob.ts"; | ||
import { exists } from "https://deno.land/[email protected]/fs/mod.ts"; | ||
|
@@ -66,13 +66,13 @@ async function checkAndLogRuleFileAgainst(props: { | |
); | ||
return true; | ||
} else { | ||
console.log( | ||
` ${colors.bgRed( | ||
colors.brightWhite(" FAIL ") | ||
)} ${relativeEntry} ${relativeRuleEntry}\n${result.message} ${colors.dim( | ||
`(${totalTime}ms)` | ||
)}` | ||
); | ||
const tag = colors.bgRed(colors.brightWhite(" x FAIL ")); | ||
|
||
const header = ` ${tag} ${relativeRuleEntry} ${colors.dim( | ||
"=>" | ||
)} ${relativeEntry} ${colors.dim(`(${totalTime}ms)`)}`; | ||
|
||
console.log(`${header}\n \n${result.message}\n`); | ||
return false; | ||
} | ||
} | ||
|
@@ -132,7 +132,7 @@ async function checkAndLogMessageAgainstFileAndSnippet(props: { | |
} else { | ||
console.log( | ||
` ${colors.bgRed( | ||
colors.brightWhite(" FAIL ") | ||
colors.brightWhite(" x FAIL ") | ||
)} ${relativeEntry} ${msg}\n${result.message} ${colors.dim( | ||
`(${totalTime}ms)` | ||
)}` | ||
|
@@ -220,21 +220,7 @@ export async function checkRulesAgainstDiff(props: { | |
|
||
// If there's no files found, explain to the user about diffs | ||
if (files.length === 0) { | ||
console.log(` | ||
No changes found. | ||
Lintrule runs on diffs by default and skips large files | ||
or things in your .gitignore. You can run Lintrule against | ||
more changes with --diff. | ||
For example: | ||
# Changes since since two commits ago | ||
rules check --diff HEAD^^ | ||
# Changes between a branch | ||
rules check --diff main..feature | ||
`); | ||
printNoChangesFound(); | ||
Deno.exit(0); | ||
} | ||
|
||
|
@@ -256,12 +242,30 @@ For example: | |
const results = await Promise.all(promises); | ||
const failed = results.filter((r) => !r); | ||
if (failed.length > 0) { | ||
console.log(colors.bgRed(`\n ${failed.length} rules failed. `), "\n"); | ||
console.log(`\n${colors.bgRed(` ${failed.length} rules failed. `)}\n`); | ||
Deno.exit(1); | ||
} | ||
console.log(colors.dim(`\nFinished. (${Date.now() - now}ms)\n`)); | ||
} | ||
|
||
function printNoChangesFound() { | ||
console.log(` | ||
No changes found. | ||
Lintrule runs on diffs by default and skips large files | ||
or things in your .gitignore. You can run Lintrule against | ||
more changes with --diff. | ||
For example: | ||
# Changes since since two commits ago | ||
rules check --diff HEAD^^ | ||
# Changes between a branch | ||
rules check --diff main..feature | ||
`); | ||
} | ||
|
||
async function checkMessageAgainstDiff(props: { | ||
host: string; | ||
accessToken: string; | ||
|
@@ -281,6 +285,11 @@ async function checkMessageAgainstDiff(props: { | |
throw new Error("Too many files to check at once. Please check less files"); | ||
} | ||
|
||
if (files.length === 0) { | ||
printNoChangesFound(); | ||
Deno.exit(0); | ||
} | ||
|
||
console.log(colors.dim(`\nFound ${files.length} changed files...\n`)); | ||
|
||
const now = Date.now(); | ||
|
@@ -298,7 +307,7 @@ async function checkMessageAgainstDiff(props: { | |
const results = await Promise.all(promises); | ||
const failed = results.filter((r) => !r); | ||
if (failed.length > 0) { | ||
console.log(colors.bgRed(`\n ${failed.length} rules failed. `), "\n"); | ||
console.log(`\n${colors.bgRed(` ${failed.length} rules failed. `)}\n`); | ||
Deno.exit(1); | ||
} | ||
console.log(colors.dim(`\nFinished. (${Date.now() - now}ms)\n`)); | ||
|
@@ -379,7 +388,7 @@ async function checkMessageAgainstFiles(props: { | |
const results = await Promise.all(promises); | ||
const failed = results.filter((r) => !r); | ||
if (failed.length > 0) { | ||
console.log(colors.bgRed(`\n ${failed.length} rules failed. `), "\n"); | ||
console.log(`\n${colors.bgRed(` ${failed.length} rules failed. `)}\n`); | ||
Deno.exit(1); | ||
} | ||
console.log(colors.dim(`\nFinished. (${Date.now() - now}ms)\n`)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters