Files
base-configs/packages/prettier-config/scripts/postinstall.cjs
Ismo Vuorinen 8d3dbd89e8 feat!: module & commonjs in prettier
BREAKING CHANGE: support module, and commonjs types
2024-08-21 17:36:04 +03:00

23 lines
811 B
JavaScript

'use strict'
const fs = require('fs')
const path = require('path')
// noinspection NpmUsedModulesInstalled
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)) {
fs.writeFileSync(filePath, JSON.stringify(fileConfigObject, undefined, 2))
}