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)
12
12
fs . writeFileSync ( path . resolve ( templateDir , 'foo.js' ) , 'foo(<%- options.n %>)' )
13
13
fs . ensureDirSync ( path . resolve ( templateDir , 'bar' ) )
14
14
fs . writeFileSync ( path . resolve ( templateDir , 'bar/bar.js' ) , 'bar(<%- m %>)' )
15
+ fs . writeFileSync ( path . resolve ( templateDir , 'bar/_bar.js' ) , '.bar(<%- m %>)' )
15
16
fs . writeFileSync ( path . resolve ( templateDir , 'entry.js' ) , `
16
17
import foo from 'foo'
17
18
@@ -347,6 +348,7 @@ test('api: render fs directory', async () => {
347
348
348
349
expect ( fs . readFileSync ( '/foo.js' , 'utf-8' ) ) . toMatch ( 'foo(1)' )
349
350
expect ( fs . readFileSync ( '/bar/bar.js' , 'utf-8' ) ) . toMatch ( 'bar(2)' )
351
+ expect ( fs . readFileSync ( '/bar/.bar.js' , 'utf-8' ) ) . toMatch ( '.bar(2)' )
350
352
expect ( fs . readFileSync ( '/replace.js' , 'utf-8' ) ) . toMatch ( 'baz(2)' )
351
353
expect ( fs . readFileSync ( '/multi-replace.js' , 'utf-8' ) ) . toMatch ( 'baz(1)\nqux(2)' )
352
354
expect ( fs . readFileSync ( '/.gitignore' , 'utf-8' ) ) . toMatch ( 'foo' )
Original file line number Diff line number Diff line change @@ -169,7 +169,7 @@ class GeneratorAPI {
169
169
const globby = require ( 'globby' )
170
170
const _files = await globby ( [ '**/*' ] , { cwd : source } )
171
171
for ( const rawPath of _files ) {
172
- const targetPath = rawPath . split ( path . sep ) . map ( filename => {
172
+ const targetPath = rawPath . split ( '/' ) . map ( filename => {
173
173
// dotfiles are ignored when published to npm, therefore in templates
174
174
// we need to use underscore instead (e.g. "_gitignore")
175
175
if ( filename . charAt ( 0 ) === '_' && filename . charAt ( 1 ) !== '_' ) {
@@ -179,7 +179,7 @@ class GeneratorAPI {
179
179
return `${ filename . slice ( 1 ) } `
180
180
}
181
181
return filename
182
- } ) . join ( path . sep )
182
+ } ) . join ( '/' )
183
183
const sourcePath = path . resolve ( source , rawPath )
184
184
const content = renderFile ( sourcePath , data , ejsOptions )
185
185
// 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