mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-04-22 04:18:33 -05:00
fix(tasks): sort
This commit is contained in:
@@ -45,7 +45,8 @@ async function list ({ file = null, api = true } = {}, context) {
|
||||
const pluginApi = api && plugins.getApi(file)
|
||||
|
||||
// Get current valid tasks in project `package.json`
|
||||
let currentTasks = Object.keys(pkg.scripts).map(
|
||||
const scriptKeys = Object.keys(pkg.scripts)
|
||||
let currentTasks = scriptKeys.map(
|
||||
name => {
|
||||
const id = `${file}:${name}`
|
||||
existing.set(id, true)
|
||||
@@ -121,6 +122,14 @@ async function list ({ file = null, api = true } = {}, context) {
|
||||
// Add the new tasks
|
||||
list = list.concat(newTasks)
|
||||
|
||||
// Sort
|
||||
const getSortScore = task => {
|
||||
const index = scriptKeys.indexOf(task.name)
|
||||
if (index !== -1) return index
|
||||
return Infinity
|
||||
}
|
||||
list = list.sort((a, b) => getSortScore(a) - getSortScore(b))
|
||||
|
||||
tasks.set(file, list)
|
||||
}
|
||||
return list
|
||||
|
||||
Reference in New Issue
Block a user