@@ -169,16 +169,17 @@ class GeneratorAPI {
169169 const globby = require ( 'globby' )
170170 const _files = await globby ( [ '**/*' ] , { cwd : source } )
171171 for ( const rawPath of _files ) {
172- let filename = path . basename ( rawPath )
173- // dotfiles are ignored when published to npm, therefore in templates
174- // we need to use underscore instead (e.g. "_gitignore")
175- if ( filename . charAt ( 0 ) === '_' && filename . charAt ( 1 ) !== '_' ) {
176- filename = `.${ filename . slice ( 1 ) } `
177- }
178- if ( filename . charAt ( 0 ) === '_' && filename . charAt ( 1 ) === '_' ) {
179- filename = `${ filename . slice ( 1 ) } `
180- }
181- const targetPath = path . join ( path . dirname ( rawPath ) , filename )
172+ const targetPath = rawPath . split ( path . sep ) . map ( filename => {
173+ // dotfiles are ignored when published to npm, therefore in templates
174+ // we need to use underscore instead (e.g. "_gitignore")
175+ if ( filename . charAt ( 0 ) === '_' && filename . charAt ( 1 ) !== '_' ) {
176+ return `.${ filename . slice ( 1 ) } `
177+ }
178+ if ( filename . charAt ( 0 ) === '_' && filename . charAt ( 1 ) === '_' ) {
179+ return `${ filename . slice ( 1 ) } `
180+ }
181+ return filename
182+ } ) . join ( path . sep )
182183 const sourcePath = path . resolve ( source , rawPath )
183184 const content = renderFile ( sourcePath , data , ejsOptions )
184185 // only set file if it's not all whitespace, or is a Buffer (binary files)
0 commit comments