Skip to content
This repository was archived by the owner on Jan 18, 2023. It is now read-only.

Commit 2ae7029

Browse files
refactoring, fixed issues
1 parent f284570 commit 2ae7029

File tree

2 files changed

+4
-50
lines changed

2 files changed

+4
-50
lines changed

src/common/constants/paths.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/lib/service-worker.ts

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1+
import { join } from 'path';
12
import { parse } from 'yaml';
23
import { yellow } from 'chalk';
3-
import { PromisifiedFs } from 'codestore-utils';
4+
import { PromisifiedFs, PathsResolverTool } from 'codestore-utils';
45
import IServiceConfig from '../interfaces/service-config.interface';
5-
import Paths, { join } from '../common/constants/paths';
66
import { WrongFolderError } from './errors';
77

88
export default class ServiceWorker {
99
private configFiles = {
1010
codestore: {
11-
path: join(Paths.ROOT, 'codestore.yaml'),
11+
path: join(PathsResolverTool.ROOT, 'codestore.yaml'),
1212
error: new WrongFolderError('You must be in code.store service root folder to invoke this command.\nCheck if codestore.yaml and schema.graphql exist.'),
1313
},
1414
schema: {
15-
path: join(Paths.SRC, 'schema.graphql'),
15+
path: PathsResolverTool.SCHEMA,
1616
error: new WrongFolderError(`Cannot find schema.graphql, make sure that you invoke this command from the service root folder or use ${yellow('cs service:pull')} to restore your graphql.schema.`),
1717
},
1818
};
@@ -37,28 +37,4 @@ export default class ServiceWorker {
3737

3838
return parse(file.toString()) as IServiceConfig;
3939
}
40-
41-
public async loadEntitiesAndMutationsPaths(): Promise<string[]> {
42-
const entities = join(process.cwd(), 'src', 'data', 'entities');
43-
const migrations = join(process.cwd(), 'src', 'data', 'migrations');
44-
45-
const entitiesPaths = await this.loadFilePaths(entities);
46-
const migrationsPaths = await this.loadFilePaths(migrations);
47-
48-
return [
49-
...entitiesPaths, ...migrationsPaths,
50-
];
51-
}
52-
53-
// eslint-disable-next-line class-methods-use-this
54-
private async loadFilePaths(path: string): Promise<string[]> {
55-
try {
56-
return await PromisifiedFs.readdir(path).then((data) => data
57-
.filter((file) => /.ts$/.test(file))
58-
.map((file) => join(path, file)));
59-
} catch (e) {
60-
if (e.code !== 'ENOENT') throw e;
61-
return [];
62-
}
63-
}
6440
}

0 commit comments

Comments
 (0)