Skip to content

Commit 9d572b9

Browse files
Templates refactor to be used with resolvePluggablePath
1 parent 83a3fbb commit 9d572b9

File tree

6 files changed

+2
-18
lines changed

6 files changed

+2
-18
lines changed

src/models/config.model.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { existsSync } from 'fs';
21
import { resolve as pathResolve } from 'path';
2+
import { resolvePluggablePath } from '../utils/files.util';
33
import { ConfigMockI, ConfigMockModel } from './config-mock.model';
44
import { TemplateConfigModel } from './template-config.model';
55

@@ -73,23 +73,7 @@ class ConfigModel implements ConfigI {
7373
get templatePath(): string {
7474
if (!this.template) { return null; }
7575
if (!this._templatePath) {
76-
// Generate the template path
77-
const template = this.template;
78-
if (existsSync(template)) {
79-
this._templatePath = template;
80-
} else {
81-
this._templatePath = pathResolve(
82-
__dirname,
83-
'..',
84-
'..',
85-
'templates',
86-
template,
87-
);
88-
}
89-
}
90-
91-
if (!existsSync(this._templatePath)) {
92-
throw `Template ${this.template} not exist`;
76+
this._templatePath = resolvePluggablePath(this.template, 'templates');
9377
}
9478
return this._templatePath;
9579
}
File renamed without changes.

0 commit comments

Comments
 (0)