Skip to content

Commit

Permalink
refact: remove getMain helper
Browse files Browse the repository at this point in the history
It is rendundant since the Generator API provides api.entryFile
  • Loading branch information
fech-dev committed Aug 26, 2021
1 parent 841e42b commit d53155a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
15 changes: 3 additions & 12 deletions generator/helpers.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
const fs = require('fs')
const path = require('path')

module.exports = function (api) {
return {
getMain() {
const tsPath = api.resolve('src/main.ts')

return fs.existsSync(tsPath) ? 'src/main.ts' : 'src/main.js'
},

updateBabelConfig (callback) {
let config, configPath

Expand Down Expand Up @@ -41,18 +36,14 @@ module.exports = function (api) {
},

updateMain (callback) {
const tsPath = api.resolve('./src/main.ts')
const jsPath = api.resolve('./src/main.js')

const mainPath = fs.existsSync(tsPath) ? tsPath : jsPath
let content = fs.readFileSync(mainPath, { encoding: 'utf8' })
let content = fs.readFileSync(api.resolve(api.entryFile), { encoding: 'utf8' })

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

lines = callback(lines)

content = lines.join('\n')
fs.writeFileSync(mainPath, content, { encoding: 'utf8' })
fs.writeFileSync(api.resolve(api.entryFile), content, { encoding: 'utf8' })
},

//TODO: refactor since is equal to updateMain
Expand Down
2 changes: 0 additions & 2 deletions generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ module.exports = (api, opts, rootOpts) => {
})

if(opts.useScss){


//Modify App.vue (import bootstrap styles)
helpers.updateApp(src => {
let styleBlockIndex = src.findIndex(line => line.match(/^<style/))
Expand Down

0 comments on commit d53155a

Please sign in to comment.