File tree Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ fs.ensureDirSync(templateDir)
1212fs . writeFileSync ( path . resolve ( templateDir , 'foo.js' ) , 'foo(<%- options.n %>)' )
1313fs . ensureDirSync ( path . resolve ( templateDir , 'bar' ) )
1414fs . writeFileSync ( path . resolve ( templateDir , 'bar/bar.js' ) , 'bar(<%- m %>)' )
15+ fs . writeFileSync ( path . resolve ( templateDir , 'bar/_bar.js' ) , '.bar(<%- m %>)' )
1516fs . writeFileSync ( path . resolve ( templateDir , 'entry.js' ) , `
1617import foo from 'foo'
1718
@@ -347,6 +348,7 @@ test('api: render fs directory', async () => {
347348
348349 expect ( fs . readFileSync ( '/foo.js' , 'utf-8' ) ) . toMatch ( 'foo(1)' )
349350 expect ( fs . readFileSync ( '/bar/bar.js' , 'utf-8' ) ) . toMatch ( 'bar(2)' )
351+ expect ( fs . readFileSync ( '/bar/.bar.js' , 'utf-8' ) ) . toMatch ( '.bar(2)' )
350352 expect ( fs . readFileSync ( '/replace.js' , 'utf-8' ) ) . toMatch ( 'baz(2)' )
351353 expect ( fs . readFileSync ( '/multi-replace.js' , 'utf-8' ) ) . toMatch ( 'baz(1)\nqux(2)' )
352354 expect ( fs . readFileSync ( '/.gitignore' , 'utf-8' ) ) . toMatch ( 'foo' )
Original file line number Diff line number Diff line change @@ -169,7 +169,7 @@ class GeneratorAPI {
169169 const globby = require ( 'globby' )
170170 const _files = await globby ( [ '**/*' ] , { cwd : source } )
171171 for ( const rawPath of _files ) {
172- const targetPath = rawPath . split ( path . sep ) . map ( filename => {
172+ const targetPath = rawPath . split ( '/' ) . map ( filename => {
173173 // dotfiles are ignored when published to npm, therefore in templates
174174 // we need to use underscore instead (e.g. "_gitignore")
175175 if ( filename . charAt ( 0 ) === '_' && filename . charAt ( 1 ) !== '_' ) {
@@ -179,7 +179,7 @@ class GeneratorAPI {
179179 return `${ filename . slice ( 1 ) } `
180180 }
181181 return filename
182- } ) . join ( path . sep )
182+ } ) . join ( '/' )
183183 const sourcePath = path . resolve ( source , rawPath )
184184 const content = renderFile ( sourcePath , data , ejsOptions )
185185 // only set file if it's not all whitespace, or is a Buffer (binary files)
You can’t perform that action at this time.
0 commit comments