Skip to content

Commit a792f58

Browse files
author
Guillaume Chau
committed
fix(generator): ENOENT error
1 parent 1b2a90c commit a792f58

File tree

1 file changed

+8
-40
lines changed

1 file changed

+8
-40
lines changed

generator/index.js

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ module.exports = (api, options, rootOptions) => {
111111
api.onCreateComplete(async () => {
112112
const execa = require('execa')
113113

114+
function run (program, args) {
115+
return execa(program, args, {
116+
preferLocal: true,
117+
})
118+
}
119+
114120
if (options.addExamples) {
115121
const appPath = api.resolve('src/App.vue')
116122
if (fs.existsSync(appPath)) {
@@ -139,7 +145,7 @@ module.exports = (api, options, rootOptions) => {
139145
}
140146
}
141147

142-
await execa('vue-cli-service', [
148+
await run('vue-cli-service', [
143149
'apollo:schema:generate',
144150
])
145151
}
@@ -184,47 +190,9 @@ module.exports = (api, options, rootOptions) => {
184190
}
185191
}
186192

187-
// Linting
188-
if (api.hasPlugin('eslint')) {
189-
// ESlint ignore
190-
if (options.addServer) {
191-
const filePath = api.resolve('.eslintignore')
192-
let content
193-
194-
if (fs.existsSync(filePath)) {
195-
content = fs.readFileSync(filePath, { encoding: 'utf8' })
196-
} else {
197-
content = ''
198-
}
199-
200-
if (content.indexOf('schema.graphql') === -1) {
201-
content += '\nschema.graphql\n'
202-
203-
fs.writeFileSync(filePath, content, { encoding: 'utf8' })
204-
}
205-
}
206-
207-
// Lint generated/modified files
208-
try {
209-
const files = ['*.js', '.*.js', 'src']
210-
if (api.hasPlugin('apollo')) {
211-
files.push('apollo-server')
212-
}
213-
execa.sync('vue-cli-service lint', [
214-
'--silent',
215-
...files,
216-
], {
217-
cleanup: true,
218-
shell: true,
219-
})
220-
} catch (e) {
221-
// No ESLint vue-cli plugin
222-
}
223-
}
224-
225193
// Schema publish
226194
if (options.publishSchema) {
227-
await execa('vue-cli-service', [
195+
await run('vue-cli-service', [
228196
'apollo:schema:publish',
229197
])
230198
}

0 commit comments

Comments
 (0)