Skip to content

Commit

Permalink
Update tsconfig.json to include all relevant file types and create ts…
Browse files Browse the repository at this point in the history
…config.json if not found in root directory
  • Loading branch information
ryota-murakami committed Oct 26, 2023
1 parent 8775e66 commit 2b7ca83
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions bin/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ async function copyConfig(filename) {

function InsertRootdirFilesPath2TSconfig() {
// get rootDir's `tsconfig.json` contents
const tsconfigPath = join(userCurrentDir, 'tsconfig.json')
const tsconfigContents = existsSync(tsconfigPath)
? readFileSync(tsconfigPath, 'utf8')
const userTsconfigPath = join(userCurrentDir, 'tsconfig.json')
const tsconfigContents = existsSync(userTsconfigPath)
? readFileSync(userTsconfigPath, 'utf8')
: null
if (tsconfigContents) {
const tsconfig = JSON.parse(tsconfigContents)
Expand All @@ -131,9 +131,14 @@ function InsertRootdirFilesPath2TSconfig() {
'./**.mjs',
...tsconfig.include,
]
writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2))
writeFileSync(userTsconfigPath, JSON.stringify(tsconfig, null, 2))
} else {
console.log('tsconfig.json not found in root directory')
// Create tsconfig.json if not exists
const packageTsconfig = JSON.parse(
readFileSync(join(packageRootDir, 'tsconfig.json'), 'utf8'),
)
packageTsconfig.include = ['./**.js', './**.ts', './**.cjs', './**.mjs']
writeFileSync(userTsconfigPath, JSON.stringify(packageTsconfig, null, 2))
}
}

Expand Down

0 comments on commit 2b7ca83

Please sign in to comment.