@@ -20,48 +20,40 @@ interface PackageVerificationResult {
20
20
}
21
21
22
22
export function verifyPackageJSON ( packageDir : string ) : PackageVerificationResult {
23
- try {
24
- // packagae.json ์กด์ฌ ์ฌ๋ถ ํ์ธ
25
- const packageJSONPath = path . join ( packageDir , PACKAGE_JSON )
26
- if ( ! fs . existsSync ( packageJSONPath ) ) {
27
- throw new NoPackageJsonError ( )
28
- }
23
+ // package.json ์กด์ฌ ์ฌ๋ถ ํ์ธ
24
+ const packageJSONPath = path . join ( packageDir , PACKAGE_JSON )
25
+ if ( ! fs . existsSync ( packageJSONPath ) ) {
26
+ throw new NoPackageJsonError ( )
27
+ }
29
28
30
- const packageJSON = JSON . parse ( fs . readFileSync ( packageJSONPath , 'utf-8' ) ) as IPackageJson
29
+ const packageJSON = JSON . parse ( fs . readFileSync ( packageJSONPath , 'utf-8' ) ) as IPackageJson
31
30
32
- // exports ํ๋ ๊ฒ์ฆ
33
- verifyExports ( packageJSON . exports )
31
+ // exports ํ๋ ๊ฒ์ฆ
32
+ verifyExports ( packageJSON . exports )
34
33
35
- // ํ์ ํ๋ ํ์ธ
36
- verifyRequiredFields ( packageJSON )
34
+ // ํ์ ํ๋ ํ์ธ
35
+ verifyRequiredFields ( packageJSON )
37
36
38
- // ํจํค์ง ํ์
ํ์ธ ํ ๊ฐ ํ์
์ ๋ง๋ ๊ตฌ์กฐ๋ฅผ ๊ฐ์ง๊ณ ์๋์ง ํ์ธ
39
- const packageType = verifyPackageType ( packageJSON )
37
+ // ํจํค์ง ํ์
ํ์ธ ํ ๊ฐ ํ์
์ ๋ง๋ ๊ตฌ์กฐ๋ฅผ ๊ฐ์ง๊ณ ์๋์ง ํ์ธ
38
+ const packageType = verifyPackageType ( packageJSON )
40
39
41
- // dual package ๋ฉด `module` ํ๋๋ฅผ ๊ฐ๋๋ก ์ ์ธ
42
- verifyPackageStructure ( packageJSON , packageType )
40
+ // dual package ๋ฉด `module` ํ๋๋ฅผ ๊ฐ๋๋ก ์ ์ธ
41
+ verifyPackageStructure ( packageJSON , packageType )
43
42
44
- // TypeScript ํจํค์ง์ธ ๊ฒฝ์ฐ ํ์
์ ์ ํ์ผ์ด ์๋์ง ํ์ธ
45
- const tsConfigPath = path . join ( packageDir , TSCONFIG_JSON )
46
- const writtenByTypescript = fs . existsSync ( tsConfigPath )
43
+ // TypeScript ํจํค์ง์ธ ๊ฒฝ์ฐ ํ์
์ ์ ํ์ผ์ด ์๋์ง ํ์ธ
44
+ const tsConfigPath = path . join ( packageDir , TSCONFIG_JSON )
45
+ const writtenByTypescript = fs . existsSync ( tsConfigPath )
47
46
48
- if ( writtenByTypescript ) {
49
- verifyTypescriptPackage ( packageJSON , packageType )
50
- }
47
+ if ( writtenByTypescript ) {
48
+ verifyTypescriptPackage ( packageJSON , packageType )
49
+ }
51
50
52
- // exports ํ๋์ ์ ์๋ ์ถ๋ ฅ ๊ฒฝ๋ก๊ฐ ์ฌ๋ฐ๋ฅธ์ง ํ์ธ
53
- verifyOutputPaths ( packageJSON , packageType , writtenByTypescript )
51
+ // exports ํ๋์ ์ ์๋ ์ถ๋ ฅ ๊ฒฝ๋ก๊ฐ ์ฌ๋ฐ๋ฅธ์ง ํ์ธ
52
+ verifyOutputPaths ( packageJSON , packageType , writtenByTypescript )
54
53
55
- return {
56
- writtenByTypescript,
57
- packageJSON,
58
- isDualPackage : packageType === 'dual' ,
59
- }
60
- } catch ( error ) {
61
- if ( error instanceof Error ) {
62
- // eslint-disable-next-line no-console
63
- console . error ( `Package.json ๊ฒ์ฆ ์คํจ: ${ error . message } ` )
64
- }
65
- throw error
54
+ return {
55
+ writtenByTypescript,
56
+ packageJSON,
57
+ isDualPackage : packageType === 'dual' ,
66
58
}
67
59
}
0 commit comments