How to use the isomorphic-git.init 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 mizchi / next-editor / src / domain / git / commands / setupInitialRepository.ts View on Github external
await writeFile(path.join(projectRoot, ".gitignore"), GIT_IGNORE)
    await writeFile(path.join(projectRoot, "scratch.md"), SCRATCH)
    console.info("Project: creating done")
  }

  try {
    await pify(fs.mkdir)("/repo")
  } catch (e) {
    // repo exists
  }

  // ensure git
  if (await existsPath(j(projectRoot, ".git"))) {
    // Pass
  } else {
    await git.init({ dir: projectRoot })
    await git.add({
      dir: "/playground",
      filepath: "README.md"
    })
    await git.add({
      dir: "/playground",
      filepath: ".gitignore"
    })
    await git.add({
      dir: "/playground",
      filepath: "scratch.md"
    })
    await git.commit({
      author: {
        email: "dummy",
        name: "system"
github mizchi / next-editor / src / lib / repository.ts View on Github external
if (await existsPath(repo.dir)) {
    console.log("Project: already exists")
  } else {
    console.log("Project: creating...")
    await mkdirInRepository(repo, "")
    await mkdirInRepository(repo, "src")
    await writeFileInRepository(repo, "README.md", "# Hello!")
    await writeFileInRepository(repo, "src/index.js", "export default {}")
    console.log("Project: creating done")
  }

  // ensure git
  if (await existsPath(j(repo.dir, ".git"))) {
    console.log(".git: already exists")
  } else {
    await git.init(repo)
  }
}
github mizchi / next-editor / src / domain / git / __testHelpers__ / helpers.ts View on Github external
export async function createTempGitProject() {
  const tempRoot = "/tmp/__tempRoot__" + uuid()
  repos.push(tempRoot)

  await fs.promises.mkdir(tempRoot)
  await git.init({ dir: tempRoot })

  return tempRoot
}
github mizchi / next-editor / scratch.js View on Github external
const main = async () => {
  fs.mkdirSync(repo.dir)
  await git.init(repo)
  fs.writeFileSync(repo.dir + "/a", "a")
  await git.add({ ...repo, filepath: "a" })
  await git.commit({
    ...repo,
    author: { name: "dummy", email: "dummy" },
    message: "Add a"
  })
  console.log("a stasus", await git.status({ ...repo, filepath: "a" }))

  fs.mkdirSync(repo.dir + "/src")
  fs.writeFileSync(repo.dir + "/src/b", "b")
  await git.add({ ...repo, filepath: "src/b" })

  console.log(
    "src/b stasus before",
    await git.status({ ...repo, filepath: "src/b" })
github nteract / nteract / applications / desktop / src / notebook / epics / git.js View on Github external
if (!content) {
        return of(
          actions.gitInitFailed({
            error: new Error("no notebook loaded"),
            contentRef: action.payload.contentRef
          })
        );
      }
      const filepath = content.filepath;
      const repo = {
        fs,
        dir: filepath.substring(0, filepath.lastIndexOf("/"))
      };
      const notificationSystem = selectors.notificationSystem(state);

      return from(git.init(repo)).pipe(
        map(
          () =>
            actions.gitInitSuccessful({
              contentRef: action.payload.contentRef
            }),
          notificationSystem.addNotification({
            title: "Repository Created",
            message: `A Git repository has been created.`,
            dismissible: true,
            position: "tr",
            level: "success"
          })
        ),
        catchError(err => actions.gitInitFailed(err))
      );
    })
github felipemanga / FemtoIDE / plugins / git.js View on Github external
onOpenProject(){
            dir = DATA.projectPath;
            if( !fs.existsSync(dir + path.sep + ".git") ){
                noGit = true;
                return;
                git.init({dir}).then(result=>{
                    log("New git initialized");
                    wasInit = true;
                }).catch(ex=>{
                    log("Error initializing git: " + ex);
                });
            }else{
                wasInit = true;
                git.currentBranch({dir, fullname:false})
                    .then(name=>log(`Currently on branch ${name}`));
            }
        }
    });
github mizchi / next-editor / src / domain / git / commands / createProject.ts View on Github external
export async function createProject(newProjectRoot: string): Promise {
  await mkdir(newProjectRoot)
  await git.init({ dir: newProjectRoot })
  const outpath = path.join(newProjectRoot, "README.md")
  await writeFile(outpath, "# New Project")
  await git.add({ dir: newProjectRoot, filepath: "README.md" })
  await git.commit({
    dir: newProjectRoot,
    author: { name: "system", email: "dummy" },
    message: "Init"
  })
}