Skip to content
This repository was archived by the owner on May 8, 2025. It is now read-only.

Commit 286fc42

Browse files
feat: replace correct ie version
fixes #26
1 parent 9187326 commit 286fc42

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

generator/helpers.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ module.exports = function (api) {
4040
}
4141
},
4242

43+
updateBrowserlist (callback) {
44+
const rcPath = api.resolve('./.browserslistrc')
45+
const config = fs.existsSync(rcPath)
46+
? callback(fs.readFileSync(rcPath, { encoding: 'utf8' }))
47+
: callback('')
48+
49+
fs.writeFileSync(
50+
rcPath,
51+
config,
52+
{ encoding: 'utf8' }
53+
)
54+
},
55+
4356
updateMain (callback) {
4457
const tsPath = api.resolve('./src/main.ts')
4558
const jsPath = api.resolve('./src/main.js')

generator/index.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,25 @@ module.exports = (api, opts, rootOpts) => {
112112
})
113113
}
114114

115+
helpers.updateBrowserlist(content => {
116+
if (content.trim() === '') {
117+
return `> 1%
118+
last 2 versions
119+
not ie <= 10
120+
`
121+
}
122+
123+
const lines = content.split(/\r?\n/g)
124+
const ieLineIndex = lines.findIndex(line => line.match(/^([^\s]*\s+|)ie\s*</))
125+
if (ieLineIndex === -1) {
126+
lines.push('not ie <= 10')
127+
} else {
128+
lines[ieLineIndex] = 'not ie <= 10'
129+
}
130+
131+
return lines.join('\n')
132+
})
133+
115134
// If a-la-carte, update babel
116135
if (opts.useAlaCarte) {
117136
helpers.updateBabelConfig(cfg => {

0 commit comments

Comments
 (0)