Skip to content

Commit

Permalink
sets dataPath in constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
nichlaes committed Oct 28, 2024
1 parent 4bb185e commit 1fd158e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
7 changes: 5 additions & 2 deletions servers/lib/src/files/git/git-files.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import { CONFIG_MODE } from '../../enums/config-mode.enum.js';

@Injectable()
export default class GitFilesService implements IFilesService {
// eslint-disable-next-line no-useless-constructor, no-empty-function
constructor() {}
private readonly dataPath: string;

constructor() {
this.dataPath = ''; //Should be set from config service
}
getMode(): CONFIG_MODE {
return CONFIG_MODE.GIT;
}
Expand Down
15 changes: 8 additions & 7 deletions servers/lib/src/files/local/local-files.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ import { CONFIG_MODE } from '../../enums/config-mode.enum.js';

@Injectable()
export default class LocalFilesService implements IFilesService {
// eslint-disable-next-line no-useless-constructor, no-empty-function
constructor(private configService: ConfigService) {}
private readonly dataPath: string;

constructor(private configService: ConfigService) {
this.dataPath = this.configService.get('LOCAL_PATH');

}
getMode(): CONFIG_MODE {
return CONFIG_MODE.LOCAL;
}

async listDirectory(path: string): Promise<Project> {
const dataPath = this.configService.get('LOCAL_PATH');
const fullPath = join(dataPath, path);

const fullPath = join(this.dataPath, path);
const files = await fs.promises.readdir(fullPath);

const edges = await Promise.all(
Expand All @@ -37,8 +39,7 @@ export default class LocalFilesService implements IFilesService {
}

async readFile(path: string): Promise<Project> {
const dataPath = this.configService.get('LOCAL_PATH');
const fullPath = join(dataPath, path);
const fullPath = join(this.dataPath, path);

try {
const content = await (
Expand Down

0 comments on commit 1fd158e

Please sign in to comment.