Some checks failed
ci/woodpecker/push/ci Pipeline failed
Co-authored-by: Jason Woltje <jason@diversecanvas.com> Co-committed-by: Jason Woltje <jason@diversecanvas.com>
31 lines
697 B
TypeScript
31 lines
697 B
TypeScript
import { constants } from 'node:fs';
|
|
import { access } from 'node:fs/promises';
|
|
import { join } from 'node:path';
|
|
|
|
import type { ProjectKind } from './types.js';
|
|
|
|
async function fileExists(filePath: string): Promise<boolean> {
|
|
try {
|
|
await access(filePath, constants.F_OK);
|
|
return true;
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
export async function detectProjectKind(projectPath: string): Promise<ProjectKind> {
|
|
if (await fileExists(join(projectPath, 'package.json'))) {
|
|
return 'node';
|
|
}
|
|
|
|
if (await fileExists(join(projectPath, 'pyproject.toml'))) {
|
|
return 'python';
|
|
}
|
|
|
|
if (await fileExists(join(projectPath, 'Cargo.toml'))) {
|
|
return 'rust';
|
|
}
|
|
|
|
return 'unknown';
|
|
}
|