Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita6e8c37

Browse files
committed
cli chrashes when tsconfig.extends doesnt resolve
1 parenta6ad745 commita6e8c37

File tree

6 files changed

+109
-337
lines changed

6 files changed

+109
-337
lines changed

‎browser/cli/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212
"dependencies": {
1313
"@tomic/lib":"workspace:*",
1414
"chalk":"^5.3.0",
15-
"get-tsconfig":"^4.8.1",
16-
"prettier":"3.0.3"
17-
},
18-
"devDependencies": {
15+
"prettier":"3.0.3",
1916
"typescript":"^5.6.3"
2017
},
2118
"description":"Generate types from Atomic Data ontologies",

‎browser/cli/src/utils.ts

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import{getTsconfig}from'get-tsconfig';
1+
import{sysastsSys,findConfigFile,readConfigFile}from'typescript';
2+
3+
constNOT_FOUND='tsconfig.json not found';
4+
constCOULD_NOT_READ='Could not read tsconfig.json';
25

36
exportconstcamelCaseify=(str:string)=>
47
str.replace(/-([a-z0-9])/g,g=>{
@@ -12,14 +15,50 @@ export const dedupe = <T>(array: T[]): T[] => {
1215
exportconstgetExtension=()=>{
1316
try{
1417
consttsconfig=getTsconfig();
15-
if(!tsconfig)return'.js';
1618
constmoduleResolution=tsconfig.config.compilerOptions?.moduleResolution;
17-
if(!moduleResolution)return'.js';
1819

19-
returnmoduleResolution==='Bundler' ?'' :'.js';
20+
if(!moduleResolution){
21+
return'.js';
22+
}
23+
24+
returnmoduleResolution.toLowerCase()==='bundler' ?'' :'.js';
2025
}catch(error){
21-
console.error('Error getting extension:',error);
26+
if(errorinstanceofError){
27+
if(error.message===NOT_FOUND){
28+
// eslint-disable-next-line no-console
29+
console.log('tsconfig.json not found, defaulting to .js imports');
30+
31+
return'.js';
32+
}
2233

23-
return'.js';
34+
if(error.message===COULD_NOT_READ){
35+
// eslint-disable-next-line no-console
36+
console.log('Could not read tsconfig.json, defaulting to .js imports');
37+
38+
return'.js';
39+
}
40+
41+
throwerror;
42+
}else{
43+
thrownewError(error);
44+
}
2445
}
2546
};
47+
48+
constgetTsconfig=()=>{
49+
// Find tsconfig.json file
50+
consttsconfigPath=findConfigFile(
51+
process.cwd(),
52+
tsSys.fileExists,
53+
'tsconfig.json',
54+
);
55+
56+
if(!tsconfigPath)thrownewError(NOT_FOUND);
57+
58+
// Read tsconfig.json file
59+
consttsconfigFile=readConfigFile(tsconfigPath,tsSys.readFile);
60+
61+
if(!tsconfigFile.config)thrownewError(COULD_NOT_READ);
62+
63+
returntsconfigFile;
64+
};

‎browser/create-template/templates/sveltekit-site/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"extends":"./.svelte-kit/tsconfig.json",
23
"compilerOptions": {
34
"allowJs":true,
45
"checkJs":true,

‎browser/e2e/tests/test-utils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ export async function changeDrive(subject: string, page: Page) {
299299
constdriveTitleText=awaitcurrentDriveTitle(page).textContent();
300300
// Get the domain from the subject to compare with the drive title
301301
constsubjectDomain=newURL(subject).hostname;
302+
302303
if(driveTitleText&&driveTitleText.trim().includes(subjectDomain)){
303304
return;
304305
}
@@ -351,6 +352,7 @@ export async function isCurrentDrive(
351352
// Remove trailing slashes
352353
constcleanUrl=urlString.replace(/\/$/,'');
353354
consturlObj=newURL(cleanUrl);
355+
354356
// Compare only hostname and path, ignoring protocol
355357
return`${urlObj.hostname}${urlObj.pathname}`;
356358
}catch(e){
@@ -364,6 +366,7 @@ export async function isCurrentDrive(
364366
returnnormalizedCurrentUrl===normalizedUrl;
365367
}catch(error){
366368
console.error('Error in isCurrentDrive:',error);
369+
367370
returnfalse;
368371
}
369372
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp