Skip to content

Commit 316d476

Browse files
author
Guillaume Chau
committed
refactor: launch + more helpful error message
1 parent 6f4890f commit 316d476

File tree

12 files changed

+27
-15
lines changed

12 files changed

+27
-15
lines changed

packages/@vue/cli-plugin-eslint/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"babel-eslint": "^8.2.5",
2727
"eslint": "^4.19.1",
2828
"eslint-loader": "^2.0.0",
29-
"eslint-plugin-vue": "^4.5.0",
30-
"launch-editor": "^2.2.1"
29+
"eslint-plugin-vue": "^4.5.0"
3130
}
3231
}

packages/@vue/cli-plugin-eslint/ui/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = api => {
2222
label: 'org.vue.eslint.suggestions.open-eslintrc.label',
2323
handler () {
2424
const file = config.foundFiles.eslint.path
25-
const launch = require('launch-editor')
25+
const { launch } = require('@vue/cli-shared-utils')
2626
launch(file)
2727
return {
2828
keep: true

packages/@vue/cli-plugin-pwa/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"access": "public"
2323
},
2424
"dependencies": {
25-
"launch-editor": "^2.2.1",
25+
"@vue/cli-shared-utils": "^3.0.0-rc.10",
2626
"workbox-webpack-plugin": "^3.3.1"
2727
},
2828
"devDependencies": {

packages/@vue/cli-plugin-pwa/ui.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ module.exports = api => {
131131
label: 'org.vue.pwa.suggestions.open-vue.label',
132132
handler () {
133133
const file = config.foundFiles.vue.path
134-
const launch = require('launch-editor')
134+
const { launch } = require('@vue/cli-shared-utils')
135135
launch(file)
136136
return {
137137
keep: true
@@ -148,7 +148,7 @@ module.exports = api => {
148148
label: 'org.vue.pwa.suggestions.open-manifest.label',
149149
handler () {
150150
const file = config.foundFiles.manifest.path
151-
const launch = require('launch-editor')
151+
const { launch } = require('@vue/cli-shared-utils')
152152
launch(file)
153153
return {
154154
keep: true

packages/@vue/cli-shared-utils/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
'object',
88
'openBrowser',
99
'pluginResolution',
10+
'launch',
1011
'request',
1112
'spinner',
1213
'validate'
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const launch = require('launch-editor')
2+
3+
exports.launch = (...args) => {
4+
const file = args[0]
5+
console.log(`Opening ${file}...`)
6+
let cb = args[args.length - 1]
7+
if (typeof cb !== 'function') {
8+
cb = null
9+
}
10+
launch(...args, (fileName, errorMessage) => {
11+
console.error(`Unable to open '${fileName}'`, errorMessage)
12+
console.log(`Try setting the EDITOR env variable. More info: https://github.com/yyx990803/launch-editor`)
13+
14+
if (cb) cb(fileName, errorMessage)
15+
})
16+
}

packages/@vue/cli-shared-utils/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"node-ipc": "^9.1.1",
2626
"opn": "^5.3.0",
2727
"ora": "^2.1.0",
28+
"launch-editor": "^2.2.1",
2829
"request": "^2.87.0",
2930
"request-promise-native": "^1.0.5",
3031
"semver": "^5.5.0",

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const launch = require('launch-editor')
1+
const { launch } = require('@vue/cli-shared-utils')
22
const path = require('path')
33
// Connectors
44
const cwd = require('./cwd')
@@ -22,9 +22,7 @@ async function openInEditor (input, context) {
2222
message: `Opening file '${query}' in code editor...`,
2323
type: 'info'
2424
}, context)
25-
launch(query, (fileName, errorMessage) => {
26-
console.error(`Unable to open '${fileName}'`, errorMessage)
27-
})
25+
launch(query)
2826
return true
2927
}
3028

packages/@vue/cli-ui/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
"graphql-type-json": "^0.2.1",
4242
"javascript-stringify": "^1.6.0",
4343
"js-yaml": "^3.12.0",
44-
"launch-editor": "^2.2.1",
4544
"lodash.merge": "^4.6.1",
4645
"lowdb": "^1.0.0",
4746
"lru-cache": "^4.1.3",

packages/@vue/cli-ui/ui-defaults/suggestions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ module.exports = api => {
5252
handler () {
5353
const file = config.foundFiles.vue.path
5454
console.log('open', file)
55-
const launch = require('launch-editor')
55+
const { launch } = require('@vue/cli-shared-utils')
5656
launch(file)
5757
return {
5858
keep: true

packages/@vue/cli/lib/config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
const fs = require('fs-extra')
22
const path = require('path')
33
const homedir = require('os').homedir()
4-
const { get, set, unset, error } = require('@vue/cli-shared-utils')
5-
const launch = require('launch-editor')
4+
const { get, set, unset, error, launch } = require('@vue/cli-shared-utils')
65

76
async function config (value, options) {
87
const file = path.resolve(homedir, '.vuerc')

packages/@vue/cli/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
"javascript-stringify": "^1.6.0",
4343
"js-yaml": "^3.12.0",
4444
"klaw-sync": "^4.0.0",
45-
"launch-editor": "^2.2.1",
4645
"lodash.clonedeep": "^4.5.0",
4746
"minimist": "^1.2.0",
4847
"recast": "^0.15.2",

0 commit comments

Comments
 (0)