-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: deploy fail when validate markdown (#948)
- Loading branch information
Showing
10 changed files
with
413 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export const getArgs = <TArgs = { [p: string]: boolean | string | number }>(): TArgs => { | ||
const args = process.argv.slice(2); | ||
const formattedArgs: { [key: string]: boolean | string | number } = {}; | ||
|
||
for (let i = 0; i < args.length; i++) { | ||
const arg = args[i]; | ||
|
||
if (arg.startsWith('--')) { | ||
const [key, value] = arg.substring(2).split('='); | ||
formattedArgs[key] = value ? value : true; | ||
} | ||
} | ||
|
||
return formattedArgs as TArgs; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,32 @@ | ||
import { createServer as createViteServer } from 'vite'; | ||
|
||
import { MarkdownInvalidError } from '../src/helpers/markdownHelper'; | ||
import { getArgs } from './binHelper'; | ||
|
||
(async (): Promise<void> => { | ||
const args = getArgs<{ ci: boolean }>(); | ||
|
||
const vite = await createViteServer({ | ||
server: { middlewareMode: true }, | ||
appType: 'custom', | ||
}); | ||
|
||
try { | ||
const { validateMarkdown } = await vite.ssrLoadModule('/src/helpers/validateMarkdownHelper.ts'); | ||
const { validateMarkdown } = await vite.ssrLoadModule('/src/helpers/markdownHelper.ts'); | ||
validateMarkdown(); | ||
vite.close(); | ||
} catch (e) { | ||
console.error(e); | ||
} finally { | ||
vite.close(); | ||
|
||
const markdownInvalidError = e as MarkdownInvalidError; | ||
if (args.ci) { | ||
console.log(`::set-output name=filePath::${markdownInvalidError.markdownFilePathRelative}`); | ||
console.log(`::set-output name=reason::${markdownInvalidError.reason}`); | ||
console.log(`::set-output name=line::${markdownInvalidError.line}`); | ||
console.log(`::set-output name=column::${markdownInvalidError.column}`); | ||
process.exit(1); | ||
} | ||
|
||
console.error(markdownInvalidError); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.