Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git add all #825

Open
Zamiell opened this issue Jul 18, 2022 · 3 comments
Open

git add all #825

Zamiell opened this issue Jul 18, 2022 · 3 comments

Comments

@Zamiell
Copy link

Zamiell commented Jul 18, 2022

Hello,

Can we add the git.addAll function as an alias to run git add --all?

@Zamiell
Copy link
Author

Zamiell commented Jul 18, 2022

Also, git.commitAll as an alias for git commit --all.

@julianwue
Copy link

+1

@q0q34
Copy link

q0q34 commented Feb 25, 2023

++
I solved the problem like this

import path from 'path';
import fs from 'fs';

const checkDirectorySync = (dir) => {
  let err;
  try {
    fs.statSync(dir);
  } catch (e) {
    err = e;
  }
  return err === undefined ? true : false;
}

const gitRootPath = (dir) => {
  dir = dir || path.resolve('.');
  if (!checkDirectorySync(dir)) {
    console.error('Error: Path is invalid');
    process.exit(1);
  }
  if (checkDirectorySync(path.resolve(dir, '.git'))) {
    return dir;
  } else {
    const parent = path.resolve(dir, '..');
    if (parent === dir) {
      console.error('Error: This directory is not a git repository');
      process.exit(1);
    }
    return gitRootPath(parent);
  }
};

export default gitRootPath;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants