Skip to content

Commit 601fb1f

Browse files
author
Guillaume Chau
committed
feat(ui): Reset CWD to project path
1 parent 921e99f commit 601fb1f

File tree

5 files changed

+25
-2
lines changed

5 files changed

+25
-2
lines changed

packages/@vue/cli-ui/src/components/FolderExplorer.vue

+11
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ import FOLDERS_FAVORITE from '../graphql/foldersFavorite.gql'
107107
import FOLDER_OPEN from '../graphql/folderOpen.gql'
108108
import FOLDER_OPEN_PARENT from '../graphql/folderOpenParent.gql'
109109
import FOLDER_SET_FAVORITE from '../graphql/folderSetFavorite.gql'
110+
import PROJECT_CWD_RESET from '../graphql/projectCwdReset.gql'
110111
111112
export default {
112113
components: {
@@ -132,6 +133,10 @@ export default {
132133
foldersFavorite: FOLDERS_FAVORITE
133134
},
134135
136+
beforeDestroy () {
137+
this.resetProjectCwd()
138+
},
139+
135140
methods: {
136141
async openFolder (path) {
137142
this.editingPath = false
@@ -209,6 +214,12 @@ export default {
209214
210215
refreshFolder () {
211216
this.openFolder(this.folderCurrent.path)
217+
},
218+
219+
resetProjectCwd () {
220+
this.$apollo.mutate({
221+
mutation: PROJECT_CWD_RESET
222+
})
212223
}
213224
}
214225
}

packages/@vue/cli-ui/src/graphql-api/connectors/projects.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,12 @@ async function getPlugins (id, context) {
322322
return []
323323
}
324324

325+
function resetCwd (context) {
326+
if (currentProject) {
327+
cwd.set(currentProject.path, context)
328+
}
329+
}
330+
325331
module.exports = {
326332
list,
327333
getCurrent,
@@ -333,5 +339,6 @@ module.exports = {
333339
import: importProject,
334340
open,
335341
remove,
336-
getPlugins
342+
getPlugins,
343+
resetCwd
337344
}

packages/@vue/cli-ui/src/graphql-api/resolvers.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ module.exports = {
5252
projectCreate: (root, { input }, context) => projects.create(input, context),
5353
projectImport: (root, { input }, context) => projects.import(input, context),
5454
projectOpen: (root, { id }, context) => projects.open(id, context),
55-
projectRemove: (root, { id }, context) => projects.remove(id, context)
55+
projectRemove: (root, { id }, context) => projects.remove(id, context),
56+
projectCwdReset: (root, args, context) => projects.resetCwd(context)
5657
},
5758

5859
Subscription: {

packages/@vue/cli-ui/src/graphql-api/type-defs.js

+1
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ type Mutation {
172172
projectOpen (id: ID!): Project!
173173
projectSetFavorite (id: ID!, favorite: Int!): Project!
174174
projectRemove (id: ID!): Boolean!
175+
projectCwdReset: String
175176
presetApply (id: ID!): ProjectCreation
176177
featureSetEnabled (id: ID!, enabled: Boolean): Feature
177178
pluginAdd (id: ID!): Plugin
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
mutation projectCwdReset {
2+
projectCwdReset
3+
}

0 commit comments

Comments
 (0)