@@ -8,22 +8,25 @@ const solution = 'npx template-oss-apply --force'
8
8
9
9
const run = async ( type , dir , files , options ) => {
10
10
const res = [ ]
11
- const rel = ( f ) => relative ( options . root , f )
11
+ const rel = f => relative ( options . root , f )
12
12
const { add : addFiles , rm : rmFiles } = files
13
13
14
- const rm = await rmEach ( dir , rmFiles , options , ( f ) => rel ( f ) )
15
- const [ add , update ] = partition ( await parseEach ( dir , addFiles , options , { } , async ( p ) => {
16
- const diff = await p . applyDiff ( )
17
- const target = rel ( p . target )
18
- if ( diff === null ) {
19
- // needs to be added
20
- return target
21
- } else if ( diff === true ) {
22
- // its ok, no diff, this is filtered out
23
- return null
24
- }
25
- return { file : target , diff }
26
- } ) , ( d ) => typeof d === 'string' )
14
+ const rm = await rmEach ( dir , rmFiles , options , f => rel ( f ) )
15
+ const [ add , update ] = partition (
16
+ await parseEach ( dir , addFiles , options , { } , async p => {
17
+ const diff = await p . applyDiff ( )
18
+ const target = rel ( p . target )
19
+ if ( diff === null ) {
20
+ // needs to be added
21
+ return target
22
+ } else if ( diff === true ) {
23
+ // its ok, no diff, this is filtered out
24
+ return null
25
+ }
26
+ return { file : target , diff }
27
+ } ) ,
28
+ d => typeof d === 'string' ,
29
+ )
27
30
28
31
log . verbose ( 'check-apply' , 'rm' , rm )
29
32
if ( rm . length ) {
@@ -44,31 +47,28 @@ const run = async (type, dir, files, options) => {
44
47
}
45
48
46
49
log . verbose ( 'check-apply' , 'update' , update )
47
- res . push ( ...update . sort ( ( a , b ) => localeCompare ( a . file , b . file ) ) . map ( ( { file, diff } ) => ( {
48
- title : `The ${ type } file ${ basename ( file ) } needs to be updated:` ,
49
- body : [ `${ file } \n${ '=' . repeat ( 40 ) } \n${ diff } ` ] ,
50
- solution,
51
- } ) ) )
50
+ res . push (
51
+ ...update
52
+ . sort ( ( a , b ) => localeCompare ( a . file , b . file ) )
53
+ . map ( ( { file, diff } ) => ( {
54
+ title : `The ${ type } file ${ basename ( file ) } needs to be updated:` ,
55
+ body : [ `${ file } \n${ '=' . repeat ( 40 ) } \n${ diff } ` ] ,
56
+ solution,
57
+ } ) ) ,
58
+ )
52
59
53
60
return res
54
61
}
55
62
56
- module . exports = [ {
57
- run : ( options ) => run (
58
- 'repo' ,
59
- options . config . repoDir ,
60
- options . config . repoFiles ,
61
- options
62
- ) ,
63
- when : ( { config : c } ) => c . applyRepo ,
64
- name : 'check-repo' ,
65
- } , {
66
- run : ( options ) => run (
67
- 'module' ,
68
- options . config . moduleDir ,
69
- options . config . moduleFiles ,
70
- options
71
- ) ,
72
- when : ( { config : c } ) => c . applyModule ,
73
- name : 'check-module' ,
74
- } ]
63
+ module . exports = [
64
+ {
65
+ run : options => run ( 'repo' , options . config . repoDir , options . config . repoFiles , options ) ,
66
+ when : ( { config : c } ) => c . applyRepo ,
67
+ name : 'check-repo' ,
68
+ } ,
69
+ {
70
+ run : options => run ( 'module' , options . config . moduleDir , options . config . moduleFiles , options ) ,
71
+ when : ( { config : c } ) => c . applyModule ,
72
+ name : 'check-module' ,
73
+ } ,
74
+ ]
0 commit comments