feat: skip config creation if one already found (#110)

This commit introduces mechanism that'll check for common configuration file locations and respects the original file.
This commit is contained in:
Ismo Vuorinen
2023-10-25 23:09:15 +03:00
committed by GitHub
parent 56362dad96
commit 9beafec486
22 changed files with 114 additions and 8 deletions

View File

@@ -2,9 +2,18 @@
const fs = require('fs')
const path = require('path')
const process = require('process')
const checkConfig = require('@ivuorinen/config-checker')
const foundConfig = checkConfig('browserslist')
if (foundConfig.length > 0) {
console.log('browserslist-config: Found existing browserslist config file, skipping creation.')
console.log('browserslist-config: If you want to create a new config file, please remove the existing one.')
console.log(`browserslist-config: Found config files at: ${foundConfig.join(', ')}`)
process.exit(0)
}
const filePath = path.join(process.env.INIT_CWD, '.browserslistrc')
const fileConfigObject = 'extends @ivuorinen/browserslist-config'
if (!fs.existsSync(filePath)) {