-
Notifications
You must be signed in to change notification settings - Fork 3
/
pathCreator.js
27 lines (22 loc) · 1.13 KB
/
pathCreator.js
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
const { join, relative } = require("path");
function createPaths(configFilePath, relativeServiceBasePath, relativeServicesPath, relativeModelsPath, relativeServerModelsPath) {
const basePath = process.cwd();
const absoluteConfigFilePath = join(basePath, configFilePath);
const absoluteServiceBasePath = join(basePath, relativeServiceBasePath);
const absoluteServicesPath = join(basePath, relativeServicesPath);
const absoluteModelsPath = join(basePath, relativeModelsPath);
const absoluteServerModelsPath = join(basePath, relativeServerModelsPath);
const serviceBasePathRelativeToServices = relative(absoluteServicesPath, absoluteServiceBasePath);
const modelsPathRelativeToServices = relative(absoluteServicesPath, absoluteModelsPath);
return {
configFile: absoluteConfigFilePath,
relativeServiceBase: serviceBasePathRelativeToServices.replace(/\\/g, "/"),
services: absoluteServicesPath,
models: absoluteModelsPath,
relativeModels: modelsPathRelativeToServices.replace(/\\/g, "/"),
serverModels: absoluteServerModelsPath
};
}
module.exports = {
createPaths
};