INNER CODE UNIT · TypeScript

resolveBaseDir

EndBug/add-and-commit · src/util.ts:15

export function resolveBaseDir(
  cwdInput: string,
  from: string = process.cwd(),
): string {
  return path.resolve(from, cwdInput || '.');
}

/**
 * Ensures `dir` exists and is a directory before constructing simple-git.
 */
export function assertWorkingDirectory(dir: string, cwdInput: string): void {
  if (!fs.existsSync(dir) || !fs.statSync(dir).isDirectory()) {
    throw new Error(
      `The cwd input '${neutralizeLogString(cwdInput || '.')}' resolved to '${neutralizeLogString(dir)}', which is not an existing directory. ` +
        'Use a path relative to the runner workspace, or an absolute path that exists ' +
        '(e.g. ${{ github.workspace }}/path — note that $GITHUB_WORKSPACE is not expanded in with:).',
    );
  }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…