UNPKG

@inlang/paraglide-js

Version:

[![Inlang-ecosystem compatibility badge](https://cdn.jsdelivr.net/gh/opral/monorepo@main/inlang/assets/md-badges/inlang.svg)](https://inlang.com)

37 lines (36 loc) 1.22 kB
import { prompt } from "../utils.js"; import childProcess from "node:child_process"; export const checkForUncommittedChanges = async (ctx) => { try { if ((await execAsync("git status --porcelain")).toString().length === 0) { return ctx; } ctx.logger.info(`You have uncommitted changes.\n\nPlease commit your changes before initializing inlang Paraglide-JS. Committing outstanding changes ensures that you don't lose any work, and see the changes the paraglide-js init command introduces.`); const response = await prompt("Do you want to initialize inlang Paraglide-JS without committing your current changes?", { type: "confirm", initial: false, }); if (response === true) { return ctx; } else { process.exit(0); } } catch { // git cli is not installed return ctx; } }; function execAsync(command) { return new Promise((resolve, reject) => { childProcess.exec(command, (error, stdout) => { if (error) { reject(error); } else { resolve(stdout); } }); }); }