mirror of
https://github.com/ivuorinen/base-configs.git
synced 2026-03-04 03:54:50 +00:00
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:
@@ -36,6 +36,7 @@
|
||||
"postinstall": "node scripts/postinstall.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ivuorinen/config-checker": "^1.1.0",
|
||||
"prettier": "2.8.8"
|
||||
},
|
||||
"gitHead": "23d15f15743fb59c1dbe658615ef2ed51c54d230"
|
||||
|
||||
@@ -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('prettier')
|
||||
|
||||
if (foundConfig.length > 0) {
|
||||
console.log('prettier-config: Found existing prettier config file, skipping creation.')
|
||||
console.log('prettier-config: If you want to create a new config file, please remove the existing one.')
|
||||
console.log(`prettier-config: Found config files at: ${foundConfig.join(', ')}`)
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
const filePath = path.join(process.env.INIT_CWD, '.prettierrc.json')
|
||||
|
||||
const fileConfigObject = '@ivuorinen/prettier-config'
|
||||
|
||||
if (!fs.existsSync(filePath)) {
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"@ivuorinen/config-checker@^1.1.0":
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@ivuorinen/config-checker/-/config-checker-1.1.0.tgz#73a996445a917627cb558ea69f616978ff97da9d"
|
||||
integrity sha512-YHQSF2yt4YZM0W9jdFXdPUB4X1AicweDJWSJtFw58GVI4+wI8+CJtoKL/Dmbn8F3B6H6gngQHwzENqw80Zsskg==
|
||||
|
||||
prettier@2.8.8:
|
||||
version "2.8.8"
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da"
|
||||
|
||||
Reference in New Issue
Block a user