Last active
October 9, 2018 19:10
-
-
Save aghArdeshir/7d387a4205be0f685d7a435766f266d4 to your computer and use it in GitHub Desktop.
reproduce simple-git bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// put it in a folder and constantly run `node reproduce-bug.js` | |
// first time may take a little long | |
const childProcess = require("child_process"); | |
const fs = require("fs"); | |
const dirs = ["somerepo1", "somerepo2"]; | |
const filename = "something.js"; | |
let counter = 0; | |
childProcess.exec( | |
fs.existsSync("node_modules") && fs.existsSync("node_modules/simple-git") | |
? "echo" | |
: "npm init -y && npm i simple-git -S", | |
() => { | |
const simpleGit = require("simple-git"); | |
new Promise(resolve => { | |
dirs.forEach(dir => { | |
if (!fs.existsSync(dir)) { | |
fs.mkdirSync(dir); | |
} | |
childProcess.exec( | |
`mkdir ${dir} && cd ${dir} && touch ${filename}`, | |
() => { | |
fs.writeFileSync(`${dir}/${filename}`, "hi\n", () => {}); | |
childProcess.exec( | |
`cd ${dir} && git init && git add ${filename} && git commit -m "some commit message"`, | |
() => { | |
counter++; | |
if(counter === dirs.length - 1){ | |
resolve(); | |
} | |
} | |
); | |
} | |
); | |
}); | |
}).then(() => { | |
dirs.forEach(dir => { | |
simpleGit(__dirname + "/" + dir).branchLocal((e, b) => { | |
console.log( | |
"--------- -------------------- branch:", | |
b.current, | |
":", | |
dir | |
); | |
}); | |
}); | |
}); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment