fix: do not generate empty file when use ts without router (#4374)

This commit is contained in:
Cédric Exbrayat
2019-07-30 10:42:00 +02:00
committed by Haoqun Jiang
parent 95ca69c390
commit 52bae8e14a
2 changed files with 19 additions and 1 deletions
@@ -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([
{
+1 -1
View File
@@ -429,7 +429,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 ''
}
}