Skip to content

Commit d53155a

Browse files
committed
refact: remove getMain helper
It is rendundant since the Generator API provides api.entryFile
1 parent 841e42b commit d53155a

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

generator/helpers.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
const fs = require('fs')
2+
const path = require('path')
23

34
module.exports = function (api) {
45
return {
5-
getMain() {
6-
const tsPath = api.resolve('src/main.ts')
7-
8-
return fs.existsSync(tsPath) ? 'src/main.ts' : 'src/main.js'
9-
},
10-
116
updateBabelConfig (callback) {
127
let config, configPath
138

@@ -41,18 +36,14 @@ module.exports = function (api) {
4136
},
4237

4338
updateMain (callback) {
44-
const tsPath = api.resolve('./src/main.ts')
45-
const jsPath = api.resolve('./src/main.js')
46-
47-
const mainPath = fs.existsSync(tsPath) ? tsPath : jsPath
48-
let content = fs.readFileSync(mainPath, { encoding: 'utf8' })
39+
let content = fs.readFileSync(api.resolve(api.entryFile), { encoding: 'utf8' })
4940

5041
let lines = content.split(/\r?\n/g)
5142

5243
lines = callback(lines)
5344

5445
content = lines.join('\n')
55-
fs.writeFileSync(mainPath, content, { encoding: 'utf8' })
46+
fs.writeFileSync(api.resolve(api.entryFile), content, { encoding: 'utf8' })
5647
},
5748

5849
//TODO: refactor since is equal to updateMain

generator/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ module.exports = (api, opts, rootOpts) => {
4040
})
4141

4242
if(opts.useScss){
43-
44-
4543
//Modify App.vue (import bootstrap styles)
4644
helpers.updateApp(src => {
4745
let styleBlockIndex = src.findIndex(line => line.match(/^<style/))

0 commit comments

Comments
 (0)