|
1 | 1 | import arg from "arg"; |
2 | 2 | import process from "node:process"; |
| 3 | +import { checkFrontmatterType } from "../lib/check-frontmatter-type"; |
3 | 4 | import { config } from "../lib/config"; |
4 | 5 | import { QiitaItem } from "../lib/entities/qiita-item"; |
5 | 6 | import { getFileSystemRepo } from "../lib/get-file-system-repo"; |
@@ -44,16 +45,22 @@ export const publish = async (argv: string[]) => { |
44 | 45 |
|
45 | 46 | // Validate |
46 | 47 | const invalidItemMessages = targetItems.reduce((acc, item) => { |
47 | | - const errors = validateItem(item); |
48 | | - if (errors.length > 0) return [...acc, { name: item.name, errors }]; |
49 | | - else return acc; |
| 48 | + const frontmatterErrors = checkFrontmatterType(item); |
| 49 | + if (frontmatterErrors.length > 0) |
| 50 | + return [...acc, { name: item.name, errors: frontmatterErrors }]; |
| 51 | + |
| 52 | + const validationErrors = validateItem(item); |
| 53 | + if (validationErrors.length > 0) |
| 54 | + return [...acc, { name: item.name, errors: validationErrors }]; |
| 55 | + |
| 56 | + return acc; |
50 | 57 | }, [] as { name: string; errors: string[] }[]); |
51 | 58 | if (invalidItemMessages.length > 0) { |
52 | 59 | console.error("Validation error:"); |
53 | 60 | invalidItemMessages.forEach((msg) => { |
54 | 61 | console.error(msg.name, msg.errors); |
55 | | - targetItems = targetItems.filter((item) => item.name !== msg.name); |
56 | 62 | }); |
| 63 | + process.exit(1); |
57 | 64 | } |
58 | 65 |
|
59 | 66 | if (targetItems.length === 0) { |
|
0 commit comments