-
Notifications
You must be signed in to change notification settings - Fork 1
/
gather.js
34 lines (30 loc) · 892 Bytes
/
gather.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const fse = require('fs-extra')
const meadows = require('./meadows')
const copy = require('recursive-copy')
const { fixSrcPath, fixDestPath, logNoSuchFile, buildCopyOptions } = require('./common')
const promises = []
const copyOptions = {
dot: true,
overwrite: true,
expand: false,
debug: false,
filter: function(e) {
return !(e.includes('node_modules'))
}
}
fse.ensureDirSync('./meadows')
const paths = fse.readdirSync('./meadows')
// Make Async
paths
.filter((path) => path !== '.git')
.forEach((path) => fse.removeSync(`./meadows/${path}`))
meadows.forEach((meadow) => {
promises.push(copy(
fixSrcPath(meadow.path),
fixDestPath(meadow.path),
buildCopyOptions(copyOptions, meadow)
).catch(logNoSuchFile))
})
Promise.all(promises)
.then(() => console.log('Done gathering.'))
.catch((err) => console.error('Error while gathering:', err))