fix(core): Fixes handling of undefined paths in tsconfig generation.

This commit is contained in:
Philipp Kunz 2024-10-28 01:24:52 +01:00
parent 5f9bd73904
commit 2b518722df
4 changed files with 17 additions and 4 deletions

View File

@ -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

View File

@ -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();

View File

@ -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.'
}

View File

@ -80,9 +80,11 @@ export class PublishModule {
const originalTsConfig = plugins.smartfile.fs.toObjectSync(
plugins.path.join(paths.cwd, 'tsconfig.json')
);
if (originalTsConfig?.compilerOptions?.paths) {
for (const path of originalTsConfig.compilerOptions.paths) {
originalTsConfig.compilerOptions.paths[path][0] = `.${originalTsConfig.compilerOptions.paths[path][0]}`;
}
}
const tsconfigJson = {
compilerOptions: {
experimentalDecorators: true,
@ -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',