Skip to content

Commit

Permalink
Merge pull request #3 from dream-num/feat/tsconfig
Browse files Browse the repository at this point in the history
feat(univer): update `references` of tsconfig after creating the project
  • Loading branch information
jikkai authored Jan 3, 2024
2 parents 7e6189a + 177e1c3 commit efbd873
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,25 @@ export async function cli (options: ICliOptions) {

createProject(fromDir, path, projectName)

// When the mode is univer, check if the tsconfig.json exists
if (mode === CliModeType.UNIVER) {
const tsConfigPath = resolve(path, '../../tsconfig.json')

if (!fs.existsSync(tsConfigPath)) {
throw new Error(`Cannot find tsconfig.json in ${chalk.underline.yellow(path)}, please check it`)
}

const tsConfig = fs.readJSONSync(tsConfigPath)

const packagesPath = fs.readdirSync(resolve(path, '../'))

tsConfig.references = packagesPath.map((packagePath) => ({
path: `./packages/${packagePath}`
}))

fs.writeJSONSync(tsConfigPath, tsConfig, { spaces: 4 })
}

console.log(chalk.green('🎉 Successfully created a new plugin!'))
} catch (error) {
// If the user force closes the prompt, exit the process
Expand Down

0 comments on commit efbd873

Please sign in to comment.