mirror of
https://github.com/ivuorinen/base-configs-prettier.git
synced 2026-02-04 01:43:17 +00:00
feat: initial import from base-configs
This commit is contained in:
24
scripts/postinstall.cjs
Normal file
24
scripts/postinstall.cjs
Normal file
@@ -0,0 +1,24 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint no-console: "off", n/no-process-exit: "off", no-undefined: "off" -- CLI app that gives users feedback */
|
||||
|
||||
const fs = require('node:fs')
|
||||
const path = require('node:path')
|
||||
// noinspection NpmUsedModulesInstalled
|
||||
const process = require('node: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)) {
|
||||
fs.writeFileSync(filePath, JSON.stringify(fileConfigObject, undefined, 2))
|
||||
}
|
||||
Reference in New Issue
Block a user