UNPKG

@supernovaio/cli

Version:

Supernova.io Command Line Interface

30 lines (28 loc) 1.3 kB
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ebe1b851-9865-578d-97cf-ab5e9211d652")}catch(e){}}(); import path from "node:path"; import { existsSync } from "node:fs"; export function createValidationServices() { return { findParentGitDirectoryLocation() { const currentDirectory = path.resolve(process.cwd()); if (hasGitMetadata(currentDirectory)) { return null; } return findParentGitRoot(currentDirectory); }, }; } function findParentGitRoot(startDirectory) { let currentDirectory = path.dirname(startDirectory); while (currentDirectory !== path.dirname(currentDirectory)) { if (hasGitMetadata(currentDirectory)) return currentDirectory; currentDirectory = path.dirname(currentDirectory); } return hasGitMetadata(currentDirectory) ? currentDirectory : null; } function hasGitMetadata(directoryPath) { return existsSync(path.join(directoryPath, ".git")); } //# sourceMappingURL=validation-service.js.map //# debugId=ebe1b851-9865-578d-97cf-ab5e9211d652