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

@@ -36,7 +36,8 @@
},
"dependencies": {
"@commitlint/cli": "18.0.0",
"@commitlint/config-conventional": "18.0.0"
"@commitlint/config-conventional": "18.0.0",
"@ivuorinen/config-checker": "^1.1.0"
},
"gitHead": "23d15f15743fb59c1dbe658615ef2ed51c54d230"
}

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('commitlint')
if (foundConfig.length > 0) {
console.log('commitlint-config: Found existing commitlint config file, skipping creation.')
console.log('commitlint-config: If you want to create a new config file, please remove the existing one.')
console.log(`commitlint-config: Found config files at: ${foundConfig.join(', ')}`)
process.exit(0)
}
const filePath = path.join(process.env.INIT_CWD, '.commitlintrc.json')
const fileConfigObject = {
extends: ['@ivuorinen/commitlint-config']
}

View File

@@ -192,6 +192,11 @@
dependencies:
"@jridgewell/trace-mapping" "0.3.9"
"@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==
"@jridgewell/resolve-uri@^3.0.3":
version "3.1.1"
resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz#c08679063f279615a3326583ba3a90d1d82cc721"