Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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"
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)
}
}
export async function createTempGitProject() {
const tempRoot = "/tmp/__tempRoot__" + uuid()
repos.push(tempRoot)
await fs.promises.mkdir(tempRoot)
await git.init({ dir: tempRoot })
return tempRoot
}
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" })
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))
);
})
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}`));
}
}
});
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"
})
}