Skip to content

Commit 416c224

Browse files
committed
Windows compatibility enhancement fix for module
1 parent 3f8c4b0 commit 416c224

17 files changed

+116
-125
lines changed

API/addRepoApi.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async function addRepoHandler(repoName, repoPath, initCheck) {
4343
.access(repoPath)
4444
.then(async () => {
4545
if (initCheck) {
46-
await execPromisified(`cd ${repoPath}; git init`);
46+
await execPromisified(`git init`, { cwd: repoPath });
4747
}
4848

4949
if (repoData) {

API/healthcheckApi.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ async function checkStatus(param) {
2727
var commandString = "";
2828

2929
switch (param) {
30-
case "OS":
31-
commandString = `uname`;
32-
break;
3330
case "GIT":
3431
commandString = `git --version`;
3532
break;

API/settingsApi.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ const { exec } = require("child_process");
22
const dotenv = require("dotenv").config();
33
const fs = require("fs");
44

5-
const util = require("util");
6-
const execPromised = util.promisify(exec);
7-
85
const fetchDatabaseFile = async () => {
96
const dbPath = process.env.DATABASE_FILE || "NO_DATABASE_FILE";
107
console.log(dbPath);

git/gitAddBranchApi.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ const execPromisified = util.promisify(exec);
55
const fetchRepopath = require("../global/fetchGitRepoPath");
66

77
const gitAddBranchApi = async (repoId, branchName) => {
8-
return await execPromisified(
9-
`cd ${fetchRepopath.getRepoPath(repoId)}; git checkout -b ${branchName}`
10-
)
8+
return await execPromisified(`git checkout -b ${branchName}`, {
9+
cwd: fetchRepopath.getRepoPath(repoId),
10+
})
1111
.then((res) => {
1212
console.log(res);
1313
return "BRANCH_CREATION_SUCCESS";

git/gitCommitChangesAPI.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ const fetchRepopath = require("../global/fetchGitRepoPath");
77
const gitCommitChangesApi = async (repoId, commitMessage) => {
88
commitMessage = commitMessage.split("||").join("\n");
99

10-
return await execPromisified(
11-
`cd ${fetchRepopath.getRepoPath(repoId)}; git commit -m "${commitMessage}"`
12-
)
10+
return await execPromisified(`git commit -m "${commitMessage}"`, {
11+
cwd: fetchRepopath.getRepoPath(repoId),
12+
})
1313
.then(({ stdout, stderr }) => {
1414
if (!stderr) {
1515
return "COMMIT_DONE";

git/gitCommitLogsAPI.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ const execPromisified = util.promisify(exec);
55

66
async function gitCommitLogHandler(repoId) {
77
const repoPath = fetchRepopath.getRepoPath(repoId);
8-
return await execPromisified(
9-
`cd ${repoPath}; git log --pretty=format:"%h||%an||%ad||%s"`
10-
).then((res) => {
8+
return await execPromisified(`git log --pretty=format:"%h||%an||%ad||%s"`, {
9+
cwd: repoPath,
10+
}).then((res) => {
1111
const { stdout, stderr } = res;
1212

1313
if (stdout && !stderr) {

git/gitFetchPullApi.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ const execPromisified = util.promisify(exec);
55
const fetchRepopath = require("../global/fetchGitRepoPath");
66

77
const gitFetchApi = async (repoId) => {
8-
return await execPromisified(
9-
`cd ${fetchRepopath.getRepoPath(repoId)}; git fetch`
10-
)
8+
return await execPromisified(`git fetch`, {
9+
cwd: fetchRepopath.getRepoPath(repoId),
10+
})
1111
.then(({ stdout, stderr }) => {
1212
if (stdout && !stderr) {
1313
const fetchResponse = stdout.trim().split("\n");
@@ -38,9 +38,9 @@ const gitFetchApi = async (repoId) => {
3838
};
3939

4040
const gitPullApi = async (repoId) => {
41-
return await execPromisified(
42-
`cd ${fetchRepopath.getRepoPath(repoId)}; git pull`
43-
)
41+
return await execPromisified(`git pull`, {
42+
cwd: fetchRepopath.getRepoPath(repoId),
43+
})
4444
.then(async ({ stdout, stderr }) => {
4545
if (stdout && !stderr) {
4646
const pullResponse = stdout.trim().split("\n");

git/gitFileDifferenceAPI.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ async function gitFileDifferenceHandler(repoId, fileName) {
1414
async function getGitFileDifference(repoId, fileName) {
1515
const repoPath = fetchRepopath.getRepoPath(repoId);
1616
return await execPromisified(
17-
`cd ${repoPath}; git diff --stat ${fileName} && echo "SPLIT___LINE" && git diff -U$(wc -l ${fileName} | xargs)`
17+
`git diff --stat ${fileName} && echo "SPLIT___LINE" && git diff -U$(wc -l ${fileName} | xargs)`,
18+
{ cwd: repoPath }
1819
).then((res) => {
1920
const { stdout, stderr } = res;
2021

git/gitGetStagedFilesAPI.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ const execPromisified = util.promisify(exec);
66
const fetchRepopath = require("../global/fetchGitRepoPath");
77

88
const getStagedFiles = async (repoId) => {
9-
return await execPromisified(
10-
`cd ${fetchRepopath.getRepoPath(repoId)}; git diff --name-only --cached`
11-
)
9+
return await execPromisified(`git diff --name-only --cached`, {
10+
cwd: fetchRepopath.getRepoPath(repoId),
11+
})
1212
.then((res) => {
1313
const { stdout, stderr } = res;
1414

git/gitGetUnpushedCommits.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ const fetchRepopath = require("../global/fetchGitRepoPath");
66

77
const gitGetUnpushedCommits = async (repoId, remoteURL) => {
88
return await execPromisified(
9-
`cd ${fetchRepopath.getRepoPath(
10-
repoId
11-
)}; git log --branches --not --remotes --pretty=format:"%h||%an||%ad||%s"`
9+
`git log --branches --not --remotes --pretty=format:"%h||%an||%ad||%s"`,
10+
{ cwd: fetchRepopath.getRepoPath(repoId) }
1211
).then((res) => {
1312
const { stdout, stderr } = res;
1413

0 commit comments

Comments
 (0)