Skip to content

Commit 325dbbd

Browse files
committed
Format with prettier
1 parent fda083e commit 325dbbd

File tree

11 files changed

+331
-305
lines changed

11 files changed

+331
-305
lines changed

bin/curator.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ if (require.main === module) {
1111
? path.resolve(process.argv[2])
1212
: path.resolve(process.cwd(), 'manifest.js')
1313

14-
curator(require(manifest)).then(() => {
15-
process.exit()
16-
}).catch(err => {
17-
console.log()
18-
console.error(err)
19-
process.exit(1)
20-
})
14+
curator(require(manifest))
15+
.then(() => {
16+
process.exit()
17+
})
18+
.catch((err) => {
19+
console.log()
20+
console.error(err)
21+
process.exit(1)
22+
})
2123
}

lib/exec.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
const { exec } = require('child_process')
44

5-
module.exports = (cmd = 'echo') => new Promise((resolve, reject) => {
6-
exec(cmd, (err, stdout, stderr) => {
7-
if (err) return reject(err)
8-
if (stderr) return reject(stderr)
9-
resolve(stdout)
5+
module.exports = (cmd = 'echo') =>
6+
new Promise((resolve, reject) => {
7+
exec(cmd, (err, stdout, stderr) => {
8+
if (err) return reject(err)
9+
if (stderr) return reject(stderr)
10+
resolve(stdout)
11+
})
1012
})
11-
})

lib/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ const createIo = require('./io')
77
const normalize = require('./normalize')
88
const install = require('./install')
99

10-
module.exports = async manifestOrFunction => {
11-
const promiseForManifest = typeof manifestOrFunction === 'function'
12-
? manifestOrFunction()
13-
: manifestOrFunction
10+
module.exports = async (manifestOrFunction) => {
11+
const promiseForManifest =
12+
typeof manifestOrFunction === 'function'
13+
? manifestOrFunction()
14+
: manifestOrFunction
1415
const manifest = await promiseForManifest
1516
const ioType = process.env.CURATOR_IO || manifest.ioType
1617
const pkgType = process.env.CURATOR_PKG || manifest.pkgType

lib/install.js

Lines changed: 63 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
const isEmpty = x => x.length === 0
3+
const isEmpty = (x) => x.length === 0
44

55
const 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

10697
module.exports = async ({ unlinks, directories, files, symlinks, io }) => {
10798
await Promise.all([...directories, ...files].map(checkAccess(io)))

lib/io/linux.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,27 @@
33
const path = require('path')
44

55
const exec = require('../exec')
6-
const {
7-
checkAccess,
8-
chmod,
9-
copyFile,
10-
makeSymlink
11-
} = require('./shared')
6+
const { checkAccess, chmod, copyFile, makeSymlink } = require('./shared')
127

138
const unlink = ({ target }) => exec(`rm -rf ${target}`)
149

1510
const makeDirRecursive = ({ target }) => exec(`mkdir -p ${target}`)
1611

17-
const chmodRecursive = ({ fmode, dmode, target }) => Promise.all([
18-
exec(`find ${target} -type f -exec chmod ${fmode.toString(8)} {} +`),
19-
exec(`find ${target} -type d -exec chmod ${dmode.toString(8)} {} +`)
20-
])
12+
const chmodRecursive = ({ fmode, dmode, target }) =>
13+
Promise.all([
14+
exec(`find ${target} -type f -exec chmod ${fmode.toString(8)} {} +`),
15+
exec(`find ${target} -type d -exec chmod ${dmode.toString(8)} {} +`)
16+
])
2117

2218
const chown = ({ owner, target }) => exec(`chown ${owner} ${target}`)
2319

24-
const chownRecursive = ({ owner, target }) => exec(`chown -R ${owner} ${target}`)
20+
const chownRecursive = ({ owner, target }) =>
21+
exec(`chown -R ${owner} ${target}`)
2522

2623
const chgrp = ({ group, target }) => exec(`chgrp ${group} ${target}`)
2724

28-
const chgrpRecursive = ({ group, target }) => exec(`chgrp -R ${group} ${target}`)
25+
const chgrpRecursive = ({ group, target }) =>
26+
exec(`chgrp -R ${group} ${target}`)
2927

3028
const overwriteDirectory = async ({ source, destination }) => {
3129
await makeDirRecursive({ target: path.dirname(destination) })

lib/io/noop.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ const chmod = ({ mode, target }) => {
1919
}
2020

2121
const chmodRecursive = ({ fmode, dmode, target }) => {
22-
console.log(`Set recursive fmode ${fmode.toString(8)} and dmode ${dmode.toString(8)} on ${target}`)
22+
console.log(
23+
`Set recursive fmode ${fmode.toString(8)} and dmode ${dmode.toString(
24+
8
25+
)} on ${target}`
26+
)
2327
}
2428

2529
const chown = ({ owner, target }) => {

lib/io/shared.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ const fsSymlink = promisify(fs.symlink)
1010

1111
const checkAccess = ({ target }) => fsAccessAsync(target, fs.constants.R_OK)
1212
const chmod = ({ mode, target }) => fsChmodAsync(target, mode)
13-
const copyFile = ({ source, destination }) => fsCopyFileAsync(source, destination)
13+
const copyFile = ({ source, destination }) =>
14+
fsCopyFileAsync(source, destination)
1415
const makeSymlink = ({ source, destination }) => fsSymlink(destination, source)
1516

1617
module.exports = {

0 commit comments

Comments
 (0)