-
Notifications
You must be signed in to change notification settings - Fork 7
/
commonsFileOperations.ts
38 lines (35 loc) · 1.27 KB
/
commonsFileOperations.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import fileUtil from '../../commons/utils/fileUtil';
import DIRECTORY_STRUCTURE from '../../commons/constants/directoryStructure';
import util from '../../generators/api/commons/util';
import constants from '../../generators/api/commons/constants';
/**
* Class which implements the logic for commons / constants files initializer actions.
*
* @export
* @class CommonsFileOperations
*/
export class CommonsFileOperations {
/**
* Initialize Util class
* @param {string} filePath - file path where api will be generated
* @return {Promise<boolean>} - true if was successfully created
*/
public async initializeUtil(filePath: string): Promise<boolean> {
return fileUtil.writeFile(
fileUtil.joinPaths(filePath, DIRECTORY_STRUCTURE.API_STRUCTURE.COMMONS, 'util.js'),
util.getUtil(),
);
}
/**
* Initialize constants classes
* @param {string} filePath - file path where api will be generated
* @return {Promise<boolean>} - true if was successfully created
*/
public async initializeConstants(filePath: string): Promise<boolean> {
return fileUtil.writeFile(
fileUtil.joinPaths(filePath, DIRECTORY_STRUCTURE.API_STRUCTURE.CONSTANTS, 'statusCode.js'),
constants.getStatusCode(),
);
}
}
export default new CommonsFileOperations();