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 # 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) ## 2024-10-28 - 1.5.0 - feat(classes.publishmodule)
Add method to create and write tsconfig.json during publish module setup 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); console.log(tspublish);
}); });
tap.test('should create a TsPublish instance', async () => {
const tspublishInstance = new tspublish.TsPublish();
expect(tspublishInstance).toBeTruthy();
});
tap.start(); tap.start();

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@git.zone/tspublish', 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.' description: 'A tool to publish multiple, concise, and small packages from monorepos, specifically for TypeScript projects within a git environment.'
} }

View File

@ -80,8 +80,10 @@ export class PublishModule {
const originalTsConfig = plugins.smartfile.fs.toObjectSync( const originalTsConfig = plugins.smartfile.fs.toObjectSync(
plugins.path.join(paths.cwd, 'tsconfig.json') plugins.path.join(paths.cwd, 'tsconfig.json')
); );
for (const path of originalTsConfig.compilerOptions.paths) { if (originalTsConfig?.compilerOptions?.paths) {
originalTsConfig.compilerOptions.paths[path][0] = `.${originalTsConfig.compilerOptions.paths[path][0]}`; for (const path of originalTsConfig.compilerOptions.paths) {
originalTsConfig.compilerOptions.paths[path][0] = `.${originalTsConfig.compilerOptions.paths[path][0]}`;
}
} }
const tsconfigJson = { const tsconfigJson = {
compilerOptions: { compilerOptions: {
@ -92,7 +94,7 @@ export class PublishModule {
moduleResolution: 'NodeNext', moduleResolution: 'NodeNext',
esModuleInterop: true, esModuleInterop: true,
verbatimModuleSyntax: true, verbatimModuleSyntax: true,
paths: originalTsConfig.compilerOptions.paths, paths: originalTsConfig?.compilerOptions?.paths,
}, },
exclude: [ exclude: [
'dist_*/**/*.d.ts', 'dist_*/**/*.d.ts',