Skip to content

Commit

Permalink
fix : simple-git cannot be used on a directory that does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Juknum committed Aug 29, 2024
1 parent 94fe816 commit 8dac9ac
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/server/actions/simple-git.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use server';
import 'server-only';

import { existsSync, readdirSync, writeFileSync } from 'fs';
import { existsSync, mkdirSync, readdirSync, writeFileSync } from 'fs';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused import mkdirSync.
import { join } from 'path';

import simpleGit from 'simple-git';
Expand All @@ -13,9 +13,14 @@ import { db } from '~/lib/db';
import { getOctokit, getUserGitHubUsername } from './octokit';

const REMOTE_REPOSITORY_URL = `https://github.com/${GITHUB_ORG_NAME}/${GITHUB_DEFAULT_REPO_NAME}.git` as const;
const LOCAL_REPOSITORY_PATH = process.env.NODE_ENV === 'production'
? '/var/www/html/data.faithfulmods.net/textures/'
: process.env.DEV_LOCAL_REPOSITORY_PATH!;
const LOCAL_REPOSITORY_PATH = (() => {
const prodPath = '/var/www/html/data.faithfulmods.net/textures/';

if (process.env.NODE_ENV !== 'production' || !existsSync(prodPath)) {
return process.env.DEV_LOCAL_REPOSITORY_PATH!;
}
return prodPath;
})()

const git = simpleGit(LOCAL_REPOSITORY_PATH);

Expand Down

0 comments on commit 8dac9ac

Please sign in to comment.