- Notifications
You must be signed in to change notification settings - Fork669
feat: support load code from local file for issue 59#149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import kebabCase = require("lodash.kebabcase"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Use ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. It's because of the issue of lodash. T_T There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. OK, it's fine. | ||
import { IProblem, langExt } from "../shared"; | ||
export function genFileExt(language: string): string { | ||
const ext: string | undefined = langExt.get(language); | ||
if (!ext) { | ||
throw new Error(`The language "${language}" is not supported.`); | ||
} | ||
return ext; | ||
} | ||
export function genFileName(node: IProblem, language: string): string { | ||
const slug: string = kebabCase(node.name); | ||
const ext: string = genFileExt(language); | ||
return `${node.id}.${slug}.${ext}`; | ||
} |