mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-17 10:17:05 +00:00
29 lines
713 B
TypeScript
29 lines
713 B
TypeScript
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
|
|
export function isAccountInstanceName(name: string): boolean {
|
|
return !name.startsWith('.');
|
|
}
|
|
|
|
export function listAccountInstanceNames(instancesDir: string): string[] {
|
|
if (!fs.existsSync(instancesDir)) {
|
|
return [];
|
|
}
|
|
|
|
return fs.readdirSync(instancesDir).filter((name) => {
|
|
if (!isAccountInstanceName(name)) {
|
|
return false;
|
|
}
|
|
|
|
try {
|
|
return fs.statSync(path.join(instancesDir, name)).isDirectory();
|
|
} catch {
|
|
return false;
|
|
}
|
|
});
|
|
}
|
|
|
|
export function listAccountInstancePaths(instancesDir: string): string[] {
|
|
return listAccountInstanceNames(instancesDir).map((name) => path.join(instancesDir, name));
|
|
}
|