UNPKG

@sentry/wizard

Version:

Sentry wizard helping you to configure your project

59 lines 2.52 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.addToGitignore = void 0; const fs = __importStar(require("fs")); const Logging_1 = require("./Logging"); const GITIGNORE_FILENAME = '.gitignore'; /** * Adds the given file to the .gitignore file. * * @param filepath the file(path) to add to the .gitignore file * @param errorMsg the error message to display if the file couldn't be added */ async function addToGitignore(filepath, errorMsg) { /** * Don't check whether the given file is ignored because: * 1. It's tricky to check it without git. * 2. Git might not be installed or accessible. * 3. It's convenient to use a module to interact with git, but it would * increase the size x2 approximately. Docs say to run the Wizard without * installing it, and duplicating the size would slow the set-up down. * 4. The Wizard is meant to be run once. * 5. A message is logged informing users it's been added to the gitignore. * 6. It will be added to the gitignore as many times as it runs - not a big * deal. * 7. It's straightforward to remove it from the gitignore. */ try { await fs.promises.appendFile(GITIGNORE_FILENAME, `\n# Sentry\n${filepath}\n`); (0, Logging_1.green)(`✓ ${filepath} added to ${GITIGNORE_FILENAME}`); } catch { (0, Logging_1.red)(errorMsg); } } exports.addToGitignore = addToGitignore; //# sourceMappingURL=Git.js.map