Skip to content

Commit 46c4ade

Browse files
committed
๐Ÿ”‡ js api์—์„œ ์—๋Ÿฌ ๋กœ๊น… ์ œ๊ฑฐ
1 parent 65796bb commit 46c4ade

File tree

1 file changed

+26
-34
lines changed

1 file changed

+26
-34
lines changed

โ€Žpackages/publint/src/index.ts

+26-34
Original file line numberDiff line numberDiff line change
@@ -20,48 +20,40 @@ interface PackageVerificationResult {
2020
}
2121

2222
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+
}
2928

30-
const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath, 'utf-8')) as IPackageJson
29+
const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath, 'utf-8')) as IPackageJson
3130

32-
// exports ํ•„๋“œ ๊ฒ€์ฆ
33-
verifyExports(packageJSON.exports)
31+
// exports ํ•„๋“œ ๊ฒ€์ฆ
32+
verifyExports(packageJSON.exports)
3433

35-
// ํ•„์ˆ˜ ํ•„๋“œ ํ™•์ธ
36-
verifyRequiredFields(packageJSON)
34+
// ํ•„์ˆ˜ ํ•„๋“œ ํ™•์ธ
35+
verifyRequiredFields(packageJSON)
3736

38-
// ํŒจํ‚ค์ง€ ํƒ€์ž… ํ™•์ธ ํ›„ ๊ฐ ํƒ€์ž…์— ๋งž๋Š” ๊ตฌ์กฐ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋Š”์ง€ ํ™•์ธ
39-
const packageType = verifyPackageType(packageJSON)
37+
// ํŒจํ‚ค์ง€ ํƒ€์ž… ํ™•์ธ ํ›„ ๊ฐ ํƒ€์ž…์— ๋งž๋Š” ๊ตฌ์กฐ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋Š”์ง€ ํ™•์ธ
38+
const packageType = verifyPackageType(packageJSON)
4039

41-
// dual package ๋ฉด `module` ํ•„๋“œ๋ฅผ ๊ฐ–๋„๋ก ์„ ์–ธ
42-
verifyPackageStructure(packageJSON, packageType)
40+
// dual package ๋ฉด `module` ํ•„๋“œ๋ฅผ ๊ฐ–๋„๋ก ์„ ์–ธ
41+
verifyPackageStructure(packageJSON, packageType)
4342

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)
4746

48-
if (writtenByTypescript) {
49-
verifyTypescriptPackage(packageJSON, packageType)
50-
}
47+
if (writtenByTypescript) {
48+
verifyTypescriptPackage(packageJSON, packageType)
49+
}
5150

52-
// exports ํ•„๋“œ์— ์ •์˜๋œ ์ถœ๋ ฅ ๊ฒฝ๋กœ๊ฐ€ ์˜ฌ๋ฐ”๋ฅธ์ง€ ํ™•์ธ
53-
verifyOutputPaths(packageJSON, packageType, writtenByTypescript)
51+
// exports ํ•„๋“œ์— ์ •์˜๋œ ์ถœ๋ ฅ ๊ฒฝ๋กœ๊ฐ€ ์˜ฌ๋ฐ”๋ฅธ์ง€ ํ™•์ธ
52+
verifyOutputPaths(packageJSON, packageType, writtenByTypescript)
5453

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',
6658
}
6759
}

0 commit comments

Comments
ย (0)