11'use strict'
22
3- const isEmpty = x => x . length === 0
3+ const isEmpty = ( x ) => x . length === 0
44
55const makeGroups = ( key , items ) => {
66 const sortedDescending = [ ...items ] . sort ( ( x , y ) => y [ key ] - x [ key ] )
@@ -15,7 +15,8 @@ const makeGroups = (key, items) => {
1515 ? [ [ item ] , ...groups ]
1616 : [ [ ...groups [ 0 ] , item ] , ...groups . slice ( 1 ) ]
1717 }
18- } , { i : Infinity , groups : [ ] }
18+ } ,
19+ { i : Infinity , groups : [ ] }
1920 )
2021
2122 return groups
@@ -28,80 +29,70 @@ const forEachGroup = async (f, items) => {
2829 }
2930}
3031
31- const checkAccess = io => async ( {
32- source
33- } ) => {
34- try {
35- await io . checkAccess ( { target : source } )
36- } catch ( err ) {
37- console . error ( `* Read failed: ${ source } ` )
38- throw err
39- }
40- }
32+ const checkAccess =
33+ ( io ) =>
34+ async ( { source } ) => {
35+ try {
36+ await io . checkAccess ( { target : source } )
37+ } catch ( err ) {
38+ console . error ( `* Read failed: ${ source } ` )
39+ throw err
40+ }
41+ }
4142
42- const installDirectory = io => async ( {
43- source,
44- destination,
45- owner,
46- group,
47- fmode,
48- dmode
49- } ) => {
50- try {
51- await io . overwriteDirectory ( { source, destination } )
52- await io . chmodRecursive ( { fmode, dmode, target : destination } )
53- await io . chownRecursive ( { owner, target : destination } )
54- await io . chgrpRecursive ( { group, target : destination } )
55- console . info ( `${ source } => ${ destination } ` )
56- } catch ( err ) {
57- console . error ( `* Install failed: ${ source } => ${ destination } ` )
58- throw err
59- }
60- }
43+ const installDirectory =
44+ ( io ) =>
45+ async ( { source, destination, owner, group, fmode, dmode } ) => {
46+ try {
47+ await io . overwriteDirectory ( { source, destination } )
48+ await io . chmodRecursive ( { fmode, dmode, target : destination } )
49+ await io . chownRecursive ( { owner, target : destination } )
50+ await io . chgrpRecursive ( { group, target : destination } )
51+ console . info ( `${ source } => ${ destination } ` )
52+ } catch ( err ) {
53+ console . error ( `* Install failed: ${ source } => ${ destination } ` )
54+ throw err
55+ }
56+ }
6157
62- const unlink = io => async ( {
63- source
64- } ) => {
65- try {
66- await io . unlink ( { target : source } )
67- console . info ( `${ source } <= /dev/null` )
68- } catch ( err ) {
69- console . error ( `* Unlink failed: ${ source } <= /dev/null #` )
70- throw err
71- }
72- }
58+ const unlink =
59+ ( io ) =>
60+ async ( { source } ) => {
61+ try {
62+ await io . unlink ( { target : source } )
63+ console . info ( `${ source } <= /dev/null` )
64+ } catch ( err ) {
65+ console . error ( `* Unlink failed: ${ source } <= /dev/null #` )
66+ throw err
67+ }
68+ }
7369
74- const installFile = io => async ( {
75- source,
76- destination,
77- owner,
78- group,
79- fmode
80- } ) => {
81- try {
82- await io . copyFile ( { source, destination } )
83- await io . chmod ( { mode : fmode , target : destination } )
84- await io . chown ( { owner, target : destination } )
85- await io . chgrp ( { group, target : destination } )
86- console . info ( `${ source } +> ${ destination } ` )
87- } catch ( err ) {
88- console . error ( `* Install failed: ${ source } +> ${ destination } ` )
89- throw err
90- }
91- }
70+ const installFile =
71+ ( io ) =>
72+ async ( { source, destination, owner, group, fmode } ) => {
73+ try {
74+ await io . copyFile ( { source, destination } )
75+ await io . chmod ( { mode : fmode , target : destination } )
76+ await io . chown ( { owner, target : destination } )
77+ await io . chgrp ( { group, target : destination } )
78+ console . info ( `${ source } +> ${ destination } ` )
79+ } catch ( err ) {
80+ console . error ( `* Install failed: ${ source } +> ${ destination } ` )
81+ throw err
82+ }
83+ }
9284
93- const installSymlink = io => async ( {
94- source,
95- destination
96- } ) => {
97- try {
98- await io . makeSymlink ( { source, destination } )
99- console . info ( `${ source } -> ${ destination } ` )
100- } catch ( err ) {
101- console . error ( `* Link failed: ${ source } -> ${ destination } ` )
102- throw err
103- }
104- }
85+ const installSymlink =
86+ ( io ) =>
87+ async ( { source, destination } ) => {
88+ try {
89+ await io . makeSymlink ( { source, destination } )
90+ console . info ( `${ source } -> ${ destination } ` )
91+ } catch ( err ) {
92+ console . error ( `* Link failed: ${ source } -> ${ destination } ` )
93+ throw err
94+ }
95+ }
10596
10697module . exports = async ( { unlinks, directories, files, symlinks, io } ) => {
10798 await Promise . all ( [ ...directories , ...files ] . map ( checkAccess ( io ) ) )
0 commit comments