expodoc
Version:
A tool to generate API documentation automatically for Express.js applications.
35 lines (34 loc) • 1.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isTypeScriptProject = isTypeScriptProject;
const node_fs_1 = require("node:fs");
const node_path_1 = require("node:path");
/**
* Recursively checks if there's at least one `.ts` file in the given directory.
*/
function hasTSFiles(dir) {
try {
const entries = (0, node_fs_1.readdirSync)(dir, { withFileTypes: true });
for (const entry of entries) {
const fullPath = (0, node_path_1.join)(dir, entry.name);
if (entry.isDirectory()) {
if (hasTSFiles(fullPath))
return true;
}
else if (entry.name.endsWith(".ts") &&
!entry.name.endsWith(".d.ts")) {
return true;
}
}
return false;
}
catch (_a) {
return false;
}
}
/**
* Determines if the current project uses TypeScript.
*/
function isTypeScriptProject() {
return (0, node_fs_1.existsSync)("tsconfig.json") || hasTSFiles("src");
}