git-js icon indicating copy to clipboard operation
git-js copied to clipboard

git add all

Open Zamiell opened this issue 2 years ago • 3 comments

Hello,

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

Zamiell avatar Jul 18 '22 02:07 Zamiell

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

Zamiell avatar Jul 18 '22 02:07 Zamiell

+1

julianwue avatar Dec 02 '22 14:12 julianwue

++ 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;

q0q34 avatar Feb 25 '23 01:02 q0q34