How to use the isomorphic-git.listFiles function in isomorphic-git

To help you get started, weโ€™ve selected a few isomorphic-git examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github InventivetalentDev / PluginBlueprint / js / versionControl.js View on Github external
return new Promise((resolve, reject) => {
        git.listFiles({dir: projectPath}).then((files) => {
            console.log("git files:", files);
            if (!files || files.length === 0) {// no repo here
                init(projectPath).then(resolve).catch(reject);
            } else {
                resolve(files);
            }
        });
    })
}
github mizchi / next-editor / src / lib / repository.ts View on Github external
export async function getGitTrackingStatus(
  projectRoot: string
): Promise {
  // buffer
  const untracked = []
  const tracked = []

  const gitFiles: string[] = await git.listFiles({ fs, dir: projectRoot })
  const gitFilepathIndexed: { [s: string]: boolean } = gitFiles.reduce(
    (acc: { [s: string]: boolean }, pathname: string) => {
      const relpath = pathname.replace(projectRoot, "")
      return { ...acc, [relpath]: true }
    },
    {}
  )

  const allFiles = await getFilesRecursively(projectRoot)
  const relativeFilepaths = allFiles.map(pathname =>
    pathname.replace(projectRoot + "/", "")
  )

  for (const relpath of relativeFilepaths) {
    if (gitFilepathIndexed[relpath]) {
      tracked.push(relpath)
github telstra / openapi-platform / packages / download-util / src / index.ts View on Github external
async function deleteAllFilesInLocalRepo(dir) {
  const filePaths = await listFiles({ fs: oldFs, dir });
  const fullFilePaths = filePaths.map(path => join(dir, path));
  await deletePaths(fullFilePaths);
}
github mizchi / next-editor / src / domain / git / queries / listGitFiles.ts View on Github external
export async function listGitFiles(
  projectRoot: string,
  ref: string = "HEAD"
): Promise<
  Array<{
    filepath: string
    gitStatus: string
  }>
> {
  const files: string[] = await git.listFiles({
    dir: projectRoot,
    ref
  })
  const statusList = await Promise.all(
    files.map(f => getFileStatus(projectRoot, f))
  )
  return zipWith(files, statusList, (filepath, gitStatus) => ({
    filepath,
    gitStatus
  }))
}
github telstra / openapi-platform / packages / git-util / src / index.ts View on Github external
async function deleteAllFilesInLocalRepo(dir) {
  const filePaths = await listFiles({ fs: oldFs, dir });
  const fullFilePaths = filePaths.map(path => join(dir, path));
  await deletePaths(fullFilePaths);
}
github mizchi / next-editor / src / domain / git / queries / getTrackingStatus.ts View on Github external
export async function getUntrackingFiles(
  projectRoot: string
): Promise {
  const tracked: string[] = await git.listFiles({
    dir: projectRoot,
    ref: "HEAD"
  })

  const files = (await getFilesRecursively(projectRoot)).map(pathname =>
    pathname.replace(projectRoot + "/", "")
  )

  return difference(files, tracked)
}
github mizchi / next-editor / src / domain / git / queries / getTrackingStatus.ts View on Github external
export async function getTrackingStatus(
  projectRoot: string
): Promise {
  const trackedByHead: string[] = await git.listFiles({
    dir: projectRoot,
    ref: "HEAD"
  })

  const trackedByIndex: string[] = await git.listFiles({
    dir: projectRoot
  })

  const tracked = uniq([...trackedByHead, ...trackedByIndex])

  const files = (await getFilesRecursively(projectRoot)).map(pathname =>
    pathname.replace(projectRoot + "/", "")
  )

  const untracked = difference(files, tracked)

  return {
    tracked,
    untracked
  }
}
github mizchi / next-editor / src / lib / repository.ts View on Github external
export async function listGitFilesInRepository(
  projectRoot: string
): Promise<
  Array<{
    filepath: string
    gitStatus: string
  }>
> {
  const files: string[] = await git.listFiles({ fs, dir: projectRoot })
  const statusList = await Promise.all(
    files.map(f => getGitStatusInRepository(projectRoot, f))
  )
  return zipWith(files, statusList, (filepath, gitStatus) => ({
    filepath,
    gitStatus
  }))
}