mirror of
https://github.com/affaan-m/ECC.git
synced 2026-11-23 16:25:30 +00:00
fix(hooks): include module extensions in edit and Stop checks
This commit is contained in:
1 parent
8abdf329ec
commit
d96596b4e0
5 files changed
+182
-7
No files matched your search
@@ -36,7 +36,7 @@ function getAccumFile(rawSessionId) {
|
||||
* @param {string} rawInput - Raw JSON string from stdin
|
||||
* @returns {string} The original input (pass-through)
|
||||
*/
|
||||
const JS_TS_EXT = /\.(ts|tsx|js|jsx)$/;
|
||||
const JS_TS_EXT = /\.(?:[cm]?[jt]s|[jt]sx)$/;
|
||||
|
||||
function appendPath(filePath, sessionId) {
|
||||
if (filePath && JS_TS_EXT.test(filePath)) {
|
||||
|
||||
@@ -39,7 +39,7 @@ function run(rawInput) {
|
||||
const input = JSON.parse(rawInput);
|
||||
const filePath = input.tool_input?.file_path;
|
||||
|
||||
if (filePath && /\.(ts|tsx|js|jsx)$/.test(filePath)) {
|
||||
if (filePath && /\.(?:[cm]?[jt]s|[jt]sx)$/.test(filePath)) {
|
||||
try {
|
||||
const resolvedFilePath = path.resolve(filePath);
|
||||
const projectRoot = findProjectRoot(path.dirname(resolvedFilePath));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* PostToolUse Hook: TypeScript check after editing .ts/.tsx files
|
||||
* PostToolUse Hook: TypeScript check after editing .ts/.tsx/.mts/.cts files
|
||||
*
|
||||
* Cross-platform (Windows, macOS, Linux)
|
||||
*
|
||||
@@ -56,7 +56,7 @@ if (require.main === module) {
|
||||
const input = JSON.parse(data);
|
||||
const filePath = input.tool_input?.file_path;
|
||||
|
||||
if (filePath && /\.(ts|tsx)$/.test(filePath)) {
|
||||
if (filePath && /\.(?:[cm]?ts|tsx)$/.test(filePath)) {
|
||||
const resolvedPath = path.resolve(filePath);
|
||||
if (!fs.existsSync(resolvedPath)) {
|
||||
process.stdout.write(data, () => process.exit(0));
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* Reads the accumulator written by post-edit-accumulator.js and processes all
|
||||
* edited files in one pass: groups files by project root for a single formatter
|
||||
* invocation per root, and groups .ts/.tsx files by tsconfig dir for a single
|
||||
* invocation per root, and groups .ts/.tsx/.mts/.cts files by tsconfig dir for a single
|
||||
* tsc --noEmit per tsconfig. The accumulator is cleared on read so repeated
|
||||
* Stop calls do not double-process files.
|
||||
*
|
||||
@@ -204,7 +204,7 @@ function main(sessionId) {
|
||||
|
||||
const byProjectRoot = new Map();
|
||||
for (const filePath of files) {
|
||||
if (!/\.(ts|tsx|js|jsx)$/.test(filePath)) continue;
|
||||
if (!/\.(?:[cm]?[jt]s|[jt]sx)$/.test(filePath)) continue;
|
||||
if (isPluginClonePath(filePath)) continue;
|
||||
const resolved = path.resolve(filePath);
|
||||
if (!fs.existsSync(resolved)) continue;
|
||||
@@ -215,7 +215,7 @@ function main(sessionId) {
|
||||
|
||||
const byTsConfigDir = new Map();
|
||||
for (const filePath of files) {
|
||||
if (!/\.(ts|tsx)$/.test(filePath)) continue;
|
||||
if (!/\.(?:[cm]?ts|tsx)$/.test(filePath)) continue;
|
||||
if (isPluginClonePath(filePath)) continue;
|
||||
const resolved = path.resolve(filePath);
|
||||
if (!fs.existsSync(resolved)) continue;
|
||||
|
||||
Reference in new issue
Block a user