Skip to content

Commit 13199f5

Browse files
author
Guillaume Chau
committedApr 10, 2019
fix(tasks): sort
1 parent ecd64c4 commit 13199f5

File tree

1 file changed

+10
-1
lines changed
  • packages/@vue/cli-ui/apollo-server/connectors

1 file changed

+10
-1
lines changed
 

‎packages/@vue/cli-ui/apollo-server/connectors/tasks.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ async function list ({ file = null, api = true } = {}, context) {
4545
const pluginApi = api && plugins.getApi(file)
4646

4747
// Get current valid tasks in project `package.json`
48-
let currentTasks = Object.keys(pkg.scripts).map(
48+
const scriptKeys = Object.keys(pkg.scripts)
49+
let currentTasks = scriptKeys.map(
4950
name => {
5051
const id = `${file}:${name}`
5152
existing.set(id, true)
@@ -121,6 +122,14 @@ async function list ({ file = null, api = true } = {}, context) {
121122
// Add the new tasks
122123
list = list.concat(newTasks)
123124

125+
// Sort
126+
const getSortScore = task => {
127+
const index = scriptKeys.indexOf(task.name)
128+
if (index !== -1) return index
129+
return Infinity
130+
}
131+
list = list.sort((a, b) => getSortScore(a) - getSortScore(b))
132+
124133
tasks.set(file, list)
125134
}
126135
return list

0 commit comments

Comments
 (0)
Please sign in to comment.