File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -10,14 +10,21 @@ const partialName = (s) => basename(s, extname(s)) // remove extension
10
10
. replace ( / ^ _ / , '' ) // remove leading underscore
11
11
. replace ( / - ( [ a - z ] ) / g, ( _ , g ) => g . toUpperCase ( ) ) // camelcase
12
12
13
- const makePartials = ( dir , setDefault ) => {
13
+ const makePartials = ( dir , isBase ) => {
14
14
const partials = fs . readdirSync ( dir ) . reduce ( ( acc , f ) => {
15
15
const partial = fs . readFileSync ( join ( dir , f ) ) . toString ( )
16
16
const name = partialName ( f )
17
- acc [ name ] = partial
18
- if ( setDefault && f . startsWith ( '_' ) ) {
17
+
18
+ if ( isBase ) {
19
+ // in the default dir, everything is a partial
20
+ // and also gets set with a default prefix for extending
21
+ acc [ name ] = partial
19
22
acc [ partialName ( `default-${ name } ` ) ] = partial
23
+ } else if ( f . startsWith ( '_' ) ) {
24
+ // otherwise only _ files get set as partials
25
+ acc [ name ] = partial
20
26
}
27
+
21
28
return acc
22
29
} , { } )
23
30
Original file line number Diff line number Diff line change @@ -219,17 +219,25 @@ t.test('content can override partials', async (t) => {
219
219
} ,
220
220
testdir : {
221
221
content_dir : {
222
+ 'index.js' : `module.exports={
223
+ rootRepo:{
224
+ add:{'.github/workflows/ci-release.yml': 'ci-release.yml'}
225
+ }
226
+ }` ,
227
+ 'ci-release.yml' : '{{> ciRelease }}\n job: 1' ,
222
228
'_step-deps.yml' : '- run: INSTALL\n' ,
223
229
'_step-test.yml' : '- run: TEST\n{{> defaultStepTest }}\n' ,
224
230
} ,
225
231
} ,
226
232
} )
227
233
await s . apply ( )
228
234
const ci = await s . readFile ( join ( '.github' , 'workflows' , 'ci.yml' ) )
235
+ const release = await s . readFile ( join ( '.github' , 'workflows' , 'ci-release.yml' ) )
229
236
t . ok ( ci . includes ( '- run: INSTALL' ) )
230
237
t . ok ( ci . includes ( '- run: TEST' ) )
231
238
t . notOk ( ci . includes ( 'npm i --ignore-scripts --no-audit --no-fund' ) )
232
239
t . ok ( ci . includes ( 'npm test --ignore-scripts' ) )
240
+ t . ok ( release . includes ( 'job: 1' ) )
233
241
} )
234
242
235
243
t . test ( 'content can extend files' , async ( t ) => {
You can’t perform that action at this time.
0 commit comments