2018-03-30 21:30:30 +02:00
|
|
|
import * as path from 'path';
|
|
|
|
import {Config} from '../common/config/private/Config';
|
2016-06-22 16:34:44 +02:00
|
|
|
|
|
|
|
class ProjectPathClass {
|
2017-06-10 22:32:56 +02:00
|
|
|
public Root: string;
|
|
|
|
public ImageFolder: string;
|
|
|
|
public ThumbnailFolder: string;
|
2017-07-03 19:17:49 +02:00
|
|
|
public FrontendFolder: string;
|
2016-06-22 16:34:44 +02:00
|
|
|
|
2017-06-10 22:32:56 +02:00
|
|
|
isAbsolutePath(pathStr: string) {
|
|
|
|
return path.resolve(pathStr) === path.normalize(pathStr);
|
|
|
|
}
|
2016-06-25 14:13:06 +02:00
|
|
|
|
2017-06-10 22:32:56 +02:00
|
|
|
normalizeRelative(pathStr: string) {
|
|
|
|
return path.join(pathStr, path.sep);
|
|
|
|
}
|
2016-12-28 15:26:19 +02:00
|
|
|
|
2017-07-14 22:56:25 +02:00
|
|
|
getAbsolutePath(pathStr: string): string {
|
|
|
|
return this.isAbsolutePath(pathStr) ? pathStr : path.join(this.Root, pathStr);
|
|
|
|
}
|
|
|
|
|
2017-06-10 22:32:56 +02:00
|
|
|
constructor() {
|
2017-07-19 10:21:52 +02:00
|
|
|
this.reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
reset() {
|
2018-03-30 21:30:30 +02:00
|
|
|
this.Root = path.join(__dirname, '/../');
|
2017-07-14 22:56:25 +02:00
|
|
|
this.ImageFolder = this.getAbsolutePath(Config.Server.imagesFolder);
|
|
|
|
this.ThumbnailFolder = this.getAbsolutePath(Config.Server.thumbnail.folder);
|
2018-03-30 21:30:30 +02:00
|
|
|
this.FrontendFolder = path.join(this.Root, 'dist');
|
2017-06-10 22:32:56 +02:00
|
|
|
}
|
2016-06-22 16:34:44 +02:00
|
|
|
}
|
|
|
|
|
2017-06-10 22:32:56 +02:00
|
|
|
export const ProjectPath = new ProjectPathClass();
|