UNPKG

@sentry/wizard

Version:

Sentry wizard helping you to configure your project

69 lines 2.46 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getUncommittedOrUntrackedFiles = exports.isInGitRepo = void 0; const childProcess = __importStar(require("child_process")); const os = __importStar(require("os")); /** * Checks if the current working directory is a git repository. * * @param opts.cwd The directory of the project. If undefined, the current process working directory will be used. * * @returns true if the current working directory is a git repository, false otherwise. */ function isInGitRepo(opts) { try { childProcess.execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore', cwd: opts.cwd, }); return true; } catch { return false; } } exports.isInGitRepo = isInGitRepo; function getUncommittedOrUntrackedFiles() { try { const gitStatus = childProcess .execSync('git status --porcelain=v1', { // we only care about stdout stdio: ['ignore', 'pipe', 'ignore'], }) .toString(); const files = gitStatus .split(os.EOL) .map((line) => line.trim()) .filter(Boolean) .map((f) => `- ${f.split(/\s+/)[1]}`); return files; } catch { return []; } } exports.getUncommittedOrUntrackedFiles = getUncommittedOrUntrackedFiles; //# sourceMappingURL=git.js.map