HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/shop.komma.nl/node_modules/git-parse/dist/util.js.flow
// @flow
import {existsSync} from 'fs';
import {join} from 'path';

export const resolveHome = (filepath: string) => {
  if (filepath[0] === '~') {
    const restOfPath: string = filepath.slice(1);
    if (!process.env.HOME)
      throw new Error('HOME environment variable is missing');
    const home: string = (process.env.HOME: string);
    return join(home, restOfPath);
  }
  return filepath;
};

export const validatePath = (resolvedPath: string) => {
  if (!existsSync(resolvedPath)) {
    throw new Error(`The path ${resolvedPath} was not found`);
  }

  if (!existsSync(join(resolvedPath, '.git'))) {
    throw new Error(
      `The directory ${resolvedPath} does not appear to be the root of a git repository.`
    );
  }
};