@@ -16,6 +16,9 @@ const bundler = require('./bundler');
1616
1717const codegen = module . exports ;
1818
19+ const HELPERS_DIRNAME = '.helpers' ;
20+ const PARTIALS_DIRNAME = '.partials' ;
21+
1922/**
2023 * Generates a file.
2124 *
@@ -148,7 +151,7 @@ const generateDirectoryStructure = config => new Promise((resolve, reject) => {
148151 fs . unlink ( path . resolve ( target_dir , template_path ) , next ) ;
149152 } else {
150153 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 } ` ) ) {
152155 // this file should only exist once.
153156 await generateFile ( {
154157 root,
@@ -168,7 +171,7 @@ const generateDirectoryStructure = config => new Promise((resolve, reject) => {
168171 walker . on ( 'directory' , async ( root , stats , next ) => {
169172 try {
170173 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 ) ;
172175 next ( ) ;
173176 } catch ( e ) {
174177 reject ( e ) ;
@@ -193,7 +196,7 @@ const generateDirectoryStructure = config => new Promise((resolve, reject) => {
193196 * @return {Promise }
194197 */
195198const 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 ) ;
197200
198201 if ( ! fs . existsSync ( helpers_dir ) ) return resolve ( ) ;
199202
@@ -231,7 +234,7 @@ const registerHelpers = config => new Promise((resolve, reject) => {
231234 * @return {Promise }
232235 */
233236const 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 ) ;
235238
236239 if ( ! fs . existsSync ( partials_dir ) ) return resolve ( ) ;
237240
0 commit comments