watskeburt
Advanced tools
Comparing version 4.0.2 to 4.1.0
@@ -63,2 +63,8 @@ import { EOL } from "node:os"; | ||
}, | ||
extensions: { | ||
type: "string", | ||
short: "x", | ||
default: | ||
"cjs,cjsx,coffee,csx,cts,js,json,jsx,litcoffee,ls,mjs,mts,svelte,ts,tsx,vue,vuex", | ||
}, | ||
help: { type: "boolean", short: "h", default: false }, | ||
@@ -65,0 +71,0 @@ version: { type: "boolean", short: "V", default: false }, |
@@ -7,4 +7,10 @@ import formatAsRegex from "./regex.js"; | ||
]); | ||
export function format(pChanges, pOutputType) { | ||
return OUTPUT_TYPE_TO_FUNCTION.get(pOutputType)(pChanges); | ||
export function format(pChanges, pOutputType, pExtensions) { | ||
const lExtensions = new Set( | ||
pExtensions | ||
.split(",") | ||
.map((pExtension) => pExtension.trim()) | ||
.map((pExtension) => `.${pExtension}`), | ||
); | ||
return OUTPUT_TYPE_TO_FUNCTION.get(pOutputType)(pChanges, lExtensions); | ||
} |
import { extname } from "node:path"; | ||
const DEFAULT_EXTENSIONS = new Set([ | ||
".cjs", | ||
".cjsx", | ||
".coffee", | ||
".csx", | ||
".cts", | ||
".js", | ||
".json", | ||
".jsx", | ||
".litcoffee", | ||
".ls", | ||
".mjs", | ||
".mts", | ||
".svelte", | ||
".ts", | ||
".tsx", | ||
".vue", | ||
".vuex", | ||
]); | ||
const DEFAULT_CHANGE_TYPES = new Set([ | ||
@@ -30,3 +11,3 @@ "modified", | ||
pChanges, | ||
pExtensions = DEFAULT_EXTENSIONS, | ||
pExtensions, | ||
pChangeTypes = DEFAULT_CHANGE_TYPES, | ||
@@ -33,0 +14,0 @@ ) { |
@@ -23,3 +23,3 @@ import { parseDiffLines } from "./parse-diff-lines.js"; | ||
const { format } = await import("./format/format.js"); | ||
return format(lChanges, lOptions.outputType); | ||
return format(lChanges, lOptions.outputType, lOptions.extensions); | ||
} | ||
@@ -26,0 +26,0 @@ export function getSHA() { |
@@ -1,2 +0,2 @@ | ||
const CHANGE_CHAR_2_CHANGE_TYPE = new Map([ | ||
const CHANGE_TYPE_MAP = new Map([ | ||
["A", "added"], | ||
@@ -14,4 +14,4 @@ ["C", "copied"], | ||
]); | ||
export function changeChar2ChangeType(pChar) { | ||
return CHANGE_CHAR_2_CHANGE_TYPE.get(pChar) ?? "unknown"; | ||
export function mapChangeType(pChar) { | ||
return CHANGE_TYPE_MAP.get(pChar) ?? "unknown"; | ||
} |
import { EOL } from "node:os"; | ||
import { changeChar2ChangeType } from "./map-change-type.js"; | ||
import { mapChangeType } from "./map-change-type.js"; | ||
const DIFF_NAME_STATUS_LINE_PATTERN = | ||
@@ -16,3 +16,3 @@ /^(?<type>[ACDMRTUXB])(?<similarity>[0-9]{3})?[ \t]+(?<name>[^ \t]+)[ \t]*(?<newName>[^ \t]+)?$/; | ||
if (lMatchResult?.groups) { | ||
lReturnValue.type = changeChar2ChangeType(lMatchResult.groups.type); | ||
lReturnValue.type = mapChangeType(lMatchResult.groups.type); | ||
if (lMatchResult.groups.newName) { | ||
@@ -19,0 +19,0 @@ lReturnValue.name = lMatchResult.groups.newName; |
import { EOL } from "node:os"; | ||
import { changeChar2ChangeType } from "./map-change-type.js"; | ||
import { mapChangeType } from "./map-change-type.js"; | ||
const DIFF_SHORT_STATUS_LINE_PATTERN = | ||
@@ -16,6 +16,4 @@ /^(?<stagedType>[ ACDMRTUXB?!])(?<unStagedType>[ ACDMRTUXB?!])[ \t]+(?<name>[^ \t]+)(( -> )(?<newName>[^ \t]+))?$/; | ||
if (lMatchResult?.groups) { | ||
const lStagedType = changeChar2ChangeType(lMatchResult.groups.stagedType); | ||
const lUnStagedType = changeChar2ChangeType( | ||
lMatchResult.groups.unStagedType, | ||
); | ||
const lStagedType = mapChangeType(lMatchResult.groups.stagedType); | ||
const lUnStagedType = mapChangeType(lMatchResult.groups.unStagedType); | ||
lReturnValue.type = | ||
@@ -22,0 +20,0 @@ lStagedType === "unmodified" ? lUnStagedType : lStagedType; |
@@ -1,1 +0,1 @@ | ||
export const VERSION = "4.0.2"; | ||
export const VERSION = "4.1.0"; |
{ | ||
"name": "watskeburt", | ||
"version": "4.0.2", | ||
"version": "4.1.0", | ||
"description": "List files changed since a git revision", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -72,3 +72,4 @@ # watskeburt | ||
The JSON output (= the array above, serialized) also contains other extensions. | ||
The JSON output (= the array above, serialized) also contains all other | ||
extensions. | ||
@@ -75,0 +76,0 @@ ``` |
@@ -55,2 +55,7 @@ export type changeType = | ||
outputType: "regex" | "json"; | ||
/** | ||
* A comma-separated list of file extensions to include in the output | ||
*/ | ||
extensions: string; | ||
} | ||
@@ -57,0 +62,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16028
105
384