contextsliver 0.1.1 → 0.1.2
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 +20 -1
- package/dist/cli.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +10 -0
- package/dist/mcp/server.js.map +1 -1
- package/dist/utils/native-check.d.ts +16 -0
- package/dist/utils/native-check.d.ts.map +1 -0
- package/dist/utils/native-check.js +71 -0
- package/dist/utils/native-check.js.map +1 -0
- package/package.json +5 -3
- package/scripts/postinstall-hint.mjs +73 -0
package/dist/cli.js
CHANGED
|
@@ -17,7 +17,26 @@ import { startMCPServer } from './mcp/server.js';
|
|
|
17
17
|
import { GraphStore } from './graph/store.js';
|
|
18
18
|
import { indexRepository } from './parser/index.js';
|
|
19
19
|
import { log } from './utils/logger.js';
|
|
20
|
-
|
|
20
|
+
// Read version from package.json so the CLI never reports a stale hardcoded value.
|
|
21
|
+
// Resolves relative to the compiled module (dist/cli.js → ../package.json), with a fallback
|
|
22
|
+
// for development (src/cli.ts → ../package.json).
|
|
23
|
+
function readVersion() {
|
|
24
|
+
const here = fileURLToPath(import.meta.url);
|
|
25
|
+
const dir = here.slice(0, here.lastIndexOf('/'));
|
|
26
|
+
const candidates = [join(dir, '..', 'package.json'), join(dir, '..', '..', 'package.json')];
|
|
27
|
+
for (const candidate of candidates) {
|
|
28
|
+
try {
|
|
29
|
+
const pkg = JSON.parse(readFileSync(candidate, 'utf-8'));
|
|
30
|
+
if (pkg.version)
|
|
31
|
+
return pkg.version;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// try next
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return '0.0.0-unknown';
|
|
38
|
+
}
|
|
39
|
+
const VERSION = readVersion();
|
|
21
40
|
const program = new Command();
|
|
22
41
|
program
|
|
23
42
|
.name('contextsliver')
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,kFAAkF;AAClF,EAAE;AACF,YAAY;AACZ,uFAAuF;AACvF,+CAA+C;AAC/C,oFAAoF;AACpF,oCAAoC;AACpC,EAAE;AACF,2FAA2F;AAC3F,2FAA2F;AAC3F,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,SAAS,EACT,UAAU,EACV,YAAY,EACZ,aAAa,EACb,cAAc,GACf,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAExC,MAAM,OAAO,GAAG,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,kFAAkF;AAClF,EAAE;AACF,YAAY;AACZ,uFAAuF;AACvF,+CAA+C;AAC/C,oFAAoF;AACpF,oCAAoC;AACpC,EAAE;AACF,2FAA2F;AAC3F,2FAA2F;AAC3F,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,SAAS,EACT,UAAU,EACV,YAAY,EACZ,aAAa,EACb,cAAc,GACf,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,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,EAAE,CAAC;QACnC,IAAI,UAAU,CAAC,SAAS,CAAC;YAAE,OAAO,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACrE,CAAC;IACD,6FAA6F;IAC7F,OAAO;QACL,yCAAyC;QACzC,EAAE;QACF,sFAAsF;QACtF,yFAAyF;QACzF,0FAA0F;QAC1F,mDAAmD;QACnD,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
package/dist/mcp/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAqBA,MAAM,WAAW,aAAa;IAC5B,4CAA4C;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB,kEAAkE;IAClE,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CA4EvE"}
|
package/dist/mcp/server.js
CHANGED
|
@@ -16,6 +16,7 @@ import { SessionManager } from '../session/manager.js';
|
|
|
16
16
|
import { ALL_TOOLS } from './tools/index.js';
|
|
17
17
|
import { startWatcher } from '../watcher/index.js';
|
|
18
18
|
import { log, logError } from '../utils/logger.js';
|
|
19
|
+
import { ensureNativeModulesOrExit } from '../utils/native-check.js';
|
|
19
20
|
/**
|
|
20
21
|
* Start the ContextSliver MCP server (stdio transport). Blocks until the client disconnects.
|
|
21
22
|
*
|
|
@@ -27,6 +28,15 @@ import { log, logError } from '../utils/logger.js';
|
|
|
27
28
|
export async function startMCPServer(opts) {
|
|
28
29
|
const projectRoot = opts.projectRoot;
|
|
29
30
|
const watch = opts.watch ?? true;
|
|
31
|
+
// 0. Verify native modules (better-sqlite3, tree-sitter) actually loaded. If their install
|
|
32
|
+
// scripts were blocked (npm v10+ default), give the user a clear fix rather than crashing
|
|
33
|
+
// deep inside a DB call.
|
|
34
|
+
const nativeOk = await ensureNativeModulesOrExit();
|
|
35
|
+
if (!nativeOk) {
|
|
36
|
+
// We still start the server so MCP clients don't hang, but every tool call will surface a
|
|
37
|
+
// helpful error. The user sees the fix instructions on stderr.
|
|
38
|
+
log('Continuing with degraded mode — tools will report the native-module error.', 'warn');
|
|
39
|
+
}
|
|
30
40
|
// 1. Ensure .sliver/ + open the database.
|
|
31
41
|
const sliverDir = join(projectRoot, '.sliver');
|
|
32
42
|
mkdirSync(sliverDir, { recursive: true });
|
package/dist/mcp/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,EAAE;AACF,8FAA8F;AAC9F,2FAA2F;AAC3F,EAAE;AACF,8FAA8F;AAC9F,iGAAiG;AACjG,2FAA2F;AAC3F,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,0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GAAG,IAAI,SAAS,CAAC;QAC3B,IAAI,EAAE,eAAe;QACrB,OAAO,EAAE,OAAO;KACjB,CAAC,CAAC;IAEH,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;QAC7B,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,CAAC;IACD,GAAG,CAAC,cAAc,SAAS,CAAC,MAAM,UAAU,CAAC,CAAC;IAE9C,wDAAwD;IACxD,IAAI,KAAK,EAAE,CAAC;QACV,IAAI,CAAC;YACH,YAAY,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QACnC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,kFAAkF;YAClF,QAAQ,CAAC,GAAG,CAAC,CAAC;YACd,GAAG,CAAC,gDAAgD,EAAE,MAAM,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;IAED,4EAA4E;IAC5E,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,GAAG,CAAC,2CAA2C,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface NativeCheckResult {
|
|
2
|
+
ok: boolean;
|
|
3
|
+
/** human-readable fix instructions if not ok */
|
|
4
|
+
message?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Verify that the native modules actually loaded (their binaries are present).
|
|
8
|
+
* Uses dynamic import so a missing binding is caught, not fatal at import time.
|
|
9
|
+
*/
|
|
10
|
+
export declare function checkNativeModules(): Promise<NativeCheckResult>;
|
|
11
|
+
/**
|
|
12
|
+
* Run the native check; if it fails, log a clear message to stderr. Returns true if healthy.
|
|
13
|
+
* Used by the server/CLI on startup so the user sees the fix instead of a cryptic stack trace.
|
|
14
|
+
*/
|
|
15
|
+
export declare function ensureNativeModulesOrExit(): Promise<boolean>;
|
|
16
|
+
//# sourceMappingURL=native-check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-check.d.ts","sourceRoot":"","sources":["../../src/utils/native-check.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,OAAO,CAAC;IACZ,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAeD;;;GAGG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,iBAAiB,CAAC,CA2BrE;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,OAAO,CAAC,CAUlE"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Native module health check.
|
|
2
|
+
//
|
|
3
|
+
// better-sqlite3 and tree-sitter ship as native (NAPI) modules whose binaries must be built
|
|
4
|
+
// (or fetched as prebuilds) during `npm install`. Modern npm (v10+) blocks install scripts by
|
|
5
|
+
// default ("npm warn allow-scripts"), so a fresh install can land WITHOUT the binaries built —
|
|
6
|
+
// in which case the first parse/DB call throws an opaque "Could not locate the bindings file".
|
|
7
|
+
//
|
|
8
|
+
// This check runs at server startup to surface that case with a clear message and the exact
|
|
9
|
+
// fix, rather than letting it fail deep inside better-sqlite3. Uses dynamic import() so a
|
|
10
|
+
// failed load is caught rather than crashing the whole module graph.
|
|
11
|
+
import { log, logError } from './logger.js';
|
|
12
|
+
/** Instructions shown when native binaries are missing. */
|
|
13
|
+
const FIX_INSTRUCTIONS = [
|
|
14
|
+
'One or more native modules failed to load. This usually means their install scripts',
|
|
15
|
+
'were blocked during `npm install` (common with npm v10+). Rebuild them with:',
|
|
16
|
+
'',
|
|
17
|
+
' npm rebuild better-sqlite3 tree-sitter tree-sitter-typescript tree-sitter-python',
|
|
18
|
+
'',
|
|
19
|
+
'If that fails, approve the install scripts first:',
|
|
20
|
+
'',
|
|
21
|
+
' npm approve-scripts better-sqlite3 tree-sitter tree-sitter-typescript tree-sitter-python',
|
|
22
|
+
' npm rebuild better-sqlite3 tree-sitter tree-sitter-typescript tree-sitter-python',
|
|
23
|
+
].join('\n');
|
|
24
|
+
/**
|
|
25
|
+
* Verify that the native modules actually loaded (their binaries are present).
|
|
26
|
+
* Uses dynamic import so a missing binding is caught, not fatal at import time.
|
|
27
|
+
*/
|
|
28
|
+
export async function checkNativeModules() {
|
|
29
|
+
const problems = [];
|
|
30
|
+
// better-sqlite3: try to instantiate + query an in-memory DB.
|
|
31
|
+
try {
|
|
32
|
+
const Database = (await import('better-sqlite3')).default;
|
|
33
|
+
const db = new Database(':memory:');
|
|
34
|
+
db.prepare('SELECT 1').get();
|
|
35
|
+
db.close();
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
problems.push(`better-sqlite3: ${err.message.split('\n')[0]}`);
|
|
39
|
+
}
|
|
40
|
+
// tree-sitter: try to construct a parser and load a grammar.
|
|
41
|
+
try {
|
|
42
|
+
const Parser = (await import('tree-sitter')).default;
|
|
43
|
+
const TS = (await import('tree-sitter-typescript')).default;
|
|
44
|
+
const p = new Parser();
|
|
45
|
+
// Cast: tree-sitter-typescript's Language type is structurally compatible but the TS
|
|
46
|
+
// definitions diverge slightly. We only care that the binary loaded, not the types here.
|
|
47
|
+
p.setLanguage(TS.typescript);
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
problems.push(`tree-sitter: ${err.message.split('\n')[0]}`);
|
|
51
|
+
}
|
|
52
|
+
if (problems.length === 0)
|
|
53
|
+
return { ok: true };
|
|
54
|
+
return { ok: false, message: `${FIX_INSTRUCTIONS}\n\nDetails: ${problems.join('; ')}` };
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Run the native check; if it fails, log a clear message to stderr. Returns true if healthy.
|
|
58
|
+
* Used by the server/CLI on startup so the user sees the fix instead of a cryptic stack trace.
|
|
59
|
+
*/
|
|
60
|
+
export async function ensureNativeModulesOrExit() {
|
|
61
|
+
const result = await checkNativeModules();
|
|
62
|
+
if (!result.ok) {
|
|
63
|
+
log('Native module check failed:', 'error');
|
|
64
|
+
logError(new Error(result.message ?? 'Unknown native module failure'));
|
|
65
|
+
log(result.message ?? '', 'error');
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
log('Native modules OK');
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=native-check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-check.js","sourceRoot":"","sources":["../../src/utils/native-check.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,EAAE;AACF,4FAA4F;AAC5F,8FAA8F;AAC9F,+FAA+F;AAC/F,+FAA+F;AAC/F,EAAE;AACF,4FAA4F;AAC5F,0FAA0F;AAC1F,qEAAqE;AACrE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAQ5C,2DAA2D;AAC3D,MAAM,gBAAgB,GAAG;IACvB,qFAAqF;IACrF,8EAA8E;IAC9E,EAAE;IACF,sFAAsF;IACtF,EAAE;IACF,mDAAmD;IACnD,EAAE;IACF,8FAA8F;IAC9F,sFAAsF;CACvF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB;IACtC,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,8DAA8D;IAC9D,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,OAAO,CAAC;QAC1D,MAAM,EAAE,GAAG,IAAI,QAAQ,CAAC,UAAU,CAAC,CAAC;QACpC,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,EAAE,CAAC;QAC7B,EAAE,CAAC,KAAK,EAAE,CAAC;IACb,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,QAAQ,CAAC,IAAI,CAAC,mBAAoB,GAAa,CAAC,OAAO,CAAC,KAAK,CAAC,I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AAmB,CAAC,CAAC;IACzB,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "contextsliver",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Universal context-management MCP server for AI coding agents. On-demand dependency-graph pruning with session awareness.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
"dist/",
|
|
37
37
|
"grammars/",
|
|
38
38
|
"templates/",
|
|
39
|
-
"hooks/"
|
|
39
|
+
"hooks/",
|
|
40
|
+
"scripts/postinstall-hint.mjs"
|
|
40
41
|
],
|
|
41
42
|
"engines": {
|
|
42
43
|
"node": ">=20.0.0"
|
|
@@ -51,7 +52,8 @@
|
|
|
51
52
|
"lint": "eslint src/ test/",
|
|
52
53
|
"format": "prettier --write src/ test/",
|
|
53
54
|
"typecheck": "tsc --noEmit",
|
|
54
|
-
"prepublishOnly": "npm run build && npm test"
|
|
55
|
+
"prepublishOnly": "npm run build && npm test",
|
|
56
|
+
"postinstall": "node scripts/postinstall-hint.mjs || true"
|
|
55
57
|
},
|
|
56
58
|
"dependencies": {
|
|
57
59
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Postinstall hint for contextsliver.
|
|
3
|
+
//
|
|
4
|
+
// ContextSliver depends on native modules (better-sqlite3, tree-sitter) that need their install
|
|
5
|
+
// scripts to run in order to fetch/build their platform binaries. Modern npm (v10+) blocks
|
|
6
|
+
// install scripts by default, so the first install can land without those binaries. This hint
|
|
7
|
+
// prints a short reminder to stderr (never stdout — that would corrupt the npm output stream)
|
|
8
|
+
// telling the user how to finish the install if so.
|
|
9
|
+
//
|
|
10
|
+
// It is intentionally harmless: it only checks for the binaries and prints a message. The
|
|
11
|
+
// `|| true` in package.json means it never blocks the install.
|
|
12
|
+
import { existsSync, readdirSync, statSync } from 'node:fs';
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
const missing = [
|
|
16
|
+
['tree-sitter', fileExistsDeep('node_modules/tree-sitter', '.node') ? null : 'tree-sitter'],
|
|
17
|
+
[
|
|
18
|
+
'better-sqlite3',
|
|
19
|
+
fileExistsDeep('node_modules/better-sqlite3', '.node') ? null : 'better-sqlite3',
|
|
20
|
+
],
|
|
21
|
+
]
|
|
22
|
+
.filter((x) => x[1])
|
|
23
|
+
.map((x) => x[1]);
|
|
24
|
+
|
|
25
|
+
if (missing.length > 0) {
|
|
26
|
+
process.stderr.write(
|
|
27
|
+
'\n[contextsliver] Native binaries for ' +
|
|
28
|
+
missing.join(', ') +
|
|
29
|
+
' were not found.\n' +
|
|
30
|
+
'If the install scripts were blocked, finish the setup with:\n\n' +
|
|
31
|
+
' npm rebuild ' +
|
|
32
|
+
missing.join(' ') +
|
|
33
|
+
'\n\n' +
|
|
34
|
+
'(or: npm approve-scripts ' +
|
|
35
|
+
missing.join(' ') +
|
|
36
|
+
' && npm rebuild ' +
|
|
37
|
+
missing.join(' ') +
|
|
38
|
+
')\n\n',
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
} catch {
|
|
42
|
+
// Never let the postinstall hint fail the install.
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Recursively check whether a directory contains a file ending in `suffix`, up to depth 3.
|
|
47
|
+
* Used to detect whether native build artifacts (e.g. *.node) were produced.
|
|
48
|
+
*/
|
|
49
|
+
function fileExistsDeep(dir, suffix, depth = 3) {
|
|
50
|
+
if (!existsSync(dir) || depth <= 0) return false;
|
|
51
|
+
let entries;
|
|
52
|
+
try {
|
|
53
|
+
entries = readdirSync(dir);
|
|
54
|
+
} catch {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
for (const entry of entries) {
|
|
58
|
+
const full = dir + '/' + entry;
|
|
59
|
+
if (entry.endsWith(suffix)) return true;
|
|
60
|
+
if (!entry.startsWith('.') && entry !== 'node_modules') {
|
|
61
|
+
let stat;
|
|
62
|
+
try {
|
|
63
|
+
stat = statSync(full);
|
|
64
|
+
} catch {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (stat.isDirectory() && fileExistsDeep(full, suffix, depth - 1)) {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
73
|
+
}
|