You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
592 B
30 lines
592 B
const fs = require('fs-extra')
|
|
|
|
module.exports = async function(apps) {
|
|
let pkg
|
|
try {
|
|
const json = await fs.readFile('package.json')
|
|
pkg = JSON.parse(json)
|
|
} catch (err) {
|
|
pkg = {}
|
|
}
|
|
|
|
return apps
|
|
.map(([name, deps]) => {
|
|
deps = deps.slice().sort((a, b) => {
|
|
return b.created - a.created
|
|
})
|
|
return [name, deps]
|
|
})
|
|
.sort(([nameA, depsA], [nameB, depsB]) => {
|
|
if (pkg.name === nameA) {
|
|
return -1
|
|
}
|
|
|
|
if (pkg.name === nameB) {
|
|
return 1
|
|
}
|
|
|
|
return depsB[0].created - depsA[0].created
|
|
})
|
|
}
|
|
|