mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-03-14 05:01:26 -05:00
fix: do not generate empty file when use ts without router (#4374)
(cherry picked from commit 52bae8e14a)
This commit is contained in:
committed by
Haoqun Jiang
parent
bb2e3e7217
commit
7c19dd61e2
@@ -17,6 +17,8 @@ test('generate files', async () => {
|
||||
expect(files['src/main.ts']).toBeTruthy()
|
||||
expect(files['src/main.js']).toBeFalsy()
|
||||
expect(files['src/App.vue']).toMatch('<script lang="ts">')
|
||||
// checks that the Home.vue file has not been created, even empty
|
||||
expect(files.hasOwnProperty('src/views/Home.vue')).toBeFalsy()
|
||||
})
|
||||
|
||||
test('classComponent', async () => {
|
||||
@@ -62,6 +64,22 @@ test('use with Babel', async () => {
|
||||
expect(files['tsconfig.json']).toMatch(`"target": "esnext"`)
|
||||
})
|
||||
|
||||
test('use with router', async () => {
|
||||
const { files } = await generateWithPlugin([
|
||||
{
|
||||
id: '@vue/cli-plugin-router',
|
||||
apply: require('@vue/cli-plugin-router/generator'),
|
||||
options: {}
|
||||
},
|
||||
{
|
||||
id: 'ts',
|
||||
apply: require('../generator'),
|
||||
options: {}
|
||||
}
|
||||
])
|
||||
expect(files['src/views/Home.vue']).toMatch('<div class=\"home\">')
|
||||
})
|
||||
|
||||
test('lint', async () => {
|
||||
const { pkg, files } = await generateWithPlugin([
|
||||
{
|
||||
|
||||
@@ -412,7 +412,7 @@ function renderFile (name, data, ejsOptions) {
|
||||
// if evaluated to falsy value, return early to avoid extra cost for extend expression
|
||||
const result = ejs.render(finalTemplate, data, ejsOptions)
|
||||
if (!result) {
|
||||
return
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user