From 2b518722df25d6b85fcd1c28feec38d97fa4edca Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Mon, 28 Oct 2024 01:24:52 +0100 Subject: [PATCH] fix(core): Fixes handling of undefined paths in tsconfig generation. --- changelog.md | 6 ++++++ test/test.ts | 5 +++++ ts/00_commitinfo_data.ts | 2 +- ts/classes.publishmodule.ts | 8 +++++--- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index fef041e..f9dc1cb 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # Changelog +## 2024-10-28 - 1.5.1 - fix(core) +Fixes handling of undefined paths in tsconfig generation. + +- Added a null check for `paths` in the original tsconfig before modifying it. +- Enhanced testing by adding a test case for creating a TsPublish instance. + ## 2024-10-28 - 1.5.0 - feat(classes.publishmodule) Add method to create and write tsconfig.json during publish module setup diff --git a/test/test.ts b/test/test.ts index f439cb6..1a2fb5e 100644 --- a/test/test.ts +++ b/test/test.ts @@ -5,4 +5,9 @@ tap.test('first test', async () => { console.log(tspublish); }); +tap.test('should create a TsPublish instance', async () => { + const tspublishInstance = new tspublish.TsPublish(); + expect(tspublishInstance).toBeTruthy(); +}); + tap.start(); diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index fc2d048..0a75f53 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@git.zone/tspublish', - version: '1.5.0', + version: '1.5.1', description: 'A tool to publish multiple, concise, and small packages from monorepos, specifically for TypeScript projects within a git environment.' } diff --git a/ts/classes.publishmodule.ts b/ts/classes.publishmodule.ts index 4f5db4c..460c33f 100644 --- a/ts/classes.publishmodule.ts +++ b/ts/classes.publishmodule.ts @@ -80,8 +80,10 @@ export class PublishModule { const originalTsConfig = plugins.smartfile.fs.toObjectSync( plugins.path.join(paths.cwd, 'tsconfig.json') ); - for (const path of originalTsConfig.compilerOptions.paths) { - originalTsConfig.compilerOptions.paths[path][0] = `.${originalTsConfig.compilerOptions.paths[path][0]}`; + if (originalTsConfig?.compilerOptions?.paths) { + for (const path of originalTsConfig.compilerOptions.paths) { + originalTsConfig.compilerOptions.paths[path][0] = `.${originalTsConfig.compilerOptions.paths[path][0]}`; + } } const tsconfigJson = { compilerOptions: { @@ -92,7 +94,7 @@ export class PublishModule { moduleResolution: 'NodeNext', esModuleInterop: true, verbatimModuleSyntax: true, - paths: originalTsConfig.compilerOptions.paths, + paths: originalTsConfig?.compilerOptions?.paths, }, exclude: [ 'dist_*/**/*.d.ts',