@@ -169,16 +169,17 @@ class GeneratorAPI {
169
169
const globby = require ( 'globby' )
170
170
const _files = await globby ( [ '**/*' ] , { cwd : source } )
171
171
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 )
182
183
const sourcePath = path . resolve ( source , rawPath )
183
184
const content = renderFile ( sourcePath , data , ejsOptions )
184
185
// only set file if it's not all whitespace, or is a Buffer (binary files)
0 commit comments