Skip to content

Commit da9b8e4

Browse files
committed
Stage initialize git
1 parent 9ccb8b5 commit da9b8e4

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"use strict";
2+
3+
const { spawnSync } = require("child_process");
4+
5+
const initializeGit = name => {
6+
const originalDirectory = process.cwd();
7+
8+
try {
9+
process.chdir(name);
10+
11+
spawnSync("git", ["init"], { stdio: "inherit" });
12+
spawnSync("git", ["add", "*"], { stdio: "inherit" });
13+
spawnSync("git", ["commit", "-m", '"First Commit"'], { stdio: "inherit" });
14+
} catch (err) {
15+
console.log(`\x1b[31m${err}\x1b[0m`);
16+
}
17+
18+
process.chdir(originalDirectory);
19+
};
20+
21+
module.exports = initializeGit;

0 commit comments

Comments
 (0)