@@ -16,6 +16,9 @@ const bundler = require('./bundler');
16
16
17
17
const codegen = module . exports ;
18
18
19
+ const HELPERS_DIRNAME = '.helpers' ;
20
+ const PARTIALS_DIRNAME = '.partials' ;
21
+
19
22
/**
20
23
* Generates a file.
21
24
*
@@ -148,7 +151,7 @@ const generateDirectoryStructure = config => new Promise((resolve, reject) => {
148
151
fs . unlink ( path . resolve ( target_dir , template_path ) , next ) ;
149
152
} else {
150
153
const file_path = path . relative ( templates_dir , path . resolve ( root , stats . name ) ) ;
151
- if ( ! file_path . startsWith ( '.partials/' ) && ! file_path . startsWith ( '.helpers/' ) ) {
154
+ if ( ! file_path . startsWith ( ` ${ PARTIALS_DIRNAME } ${ path . sep } ` ) && ! file_path . startsWith ( ` ${ HELPERS_DIRNAME } ${ path . sep } ` ) ) {
152
155
// this file should only exist once.
153
156
await generateFile ( {
154
157
root,
@@ -168,7 +171,7 @@ const generateDirectoryStructure = config => new Promise((resolve, reject) => {
168
171
walker . on ( 'directory' , async ( root , stats , next ) => {
169
172
try {
170
173
const dir_path = path . resolve ( target_dir , path . relative ( templates_dir , path . resolve ( root , stats . name ) ) ) ;
171
- if ( stats . name !== '.partials' && stats . name !== '.helpers' ) xfs . mkdirpSync ( dir_path ) ;
174
+ if ( stats . name !== PARTIALS_DIRNAME && stats . name !== HELPERS_DIRNAME ) xfs . mkdirpSync ( dir_path ) ;
172
175
next ( ) ;
173
176
} catch ( e ) {
174
177
reject ( e ) ;
@@ -193,7 +196,7 @@ const generateDirectoryStructure = config => new Promise((resolve, reject) => {
193
196
* @return {Promise }
194
197
*/
195
198
const registerHelpers = config => new Promise ( ( resolve , reject ) => {
196
- const helpers_dir = path . resolve ( config . templates , '.helpers' ) ;
199
+ const helpers_dir = path . resolve ( config . templates , HELPERS_DIRNAME ) ;
197
200
198
201
if ( ! fs . existsSync ( helpers_dir ) ) return resolve ( ) ;
199
202
@@ -231,7 +234,7 @@ const registerHelpers = config => new Promise((resolve, reject) => {
231
234
* @return {Promise }
232
235
*/
233
236
const registerPartials = config => new Promise ( ( resolve , reject ) => {
234
- const partials_dir = path . resolve ( config . templates , '.partials' ) ;
237
+ const partials_dir = path . resolve ( config . templates , PARTIALS_DIRNAME ) ;
235
238
236
239
if ( ! fs . existsSync ( partials_dir ) ) return resolve ( ) ;
237
240
0 commit comments