-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.js
52 lines (41 loc) · 1.42 KB
/
update.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const { Command } = require('commander')
const createRepository = require('./lib/create-repository')
const getMonoModules = require('./lib/get-mono-modules')
const removeGitDir = require('./lib/remove-git-dir')
const removePersistentDir = require('./lib/remove-persistent-dir')
const updateRepository = require('./lib/update-repository')
const updateSparseCheckout = require('./lib/update-sparse-checkout')
function updatePersistentRepositories () {
const monoModules = getMonoModules(true)
const repositories = new Map()
removePersistentDir()
for (const { repository, directory } of monoModules) {
const path = repository.join('/')
if (!repositories.has(path)) {
repositories.set(path, repository)
createRepository(repository, true)
}
updateSparseCheckout(repository, directory, true)
}
for (const repository of repositories.values()) {
updateRepository(repository, true)
removeGitDir(repository)
}
}
function updateRepositories () {
const monoModules = getMonoModules()
const updatedRepositories = new Set()
for (const { repository } of monoModules) {
const path = repository.join('/')
if (!updatedRepositories.has(path)) {
updatedRepositories.add(path)
updateRepository(repository)
}
}
}
module.exports = new Command('update')
.description('update installed repositories')
.action(() => {
updatePersistentRepositories()
updateRepositories()
})