提交 84a972c8 编写于 作者: J Jason Park

Refine compile/run error messages

上级 c5aa4f8b
...@@ -4,7 +4,7 @@ import child_process from 'child_process'; ...@@ -4,7 +4,7 @@ import child_process from 'child_process';
const execute = (command, cwd, { stdout = process.stdout, stderr = process.stderr } = {}) => new Promise((resolve, reject) => { const execute = (command, cwd, { stdout = process.stdout, stderr = process.stderr } = {}) => new Promise((resolve, reject) => {
if (!cwd) return reject(new Error('CWD Not Specified')); if (!cwd) return reject(new Error('CWD Not Specified'));
const child = child_process.exec(command, { cwd }, (error, stdout, stderr) => { const child = child_process.exec(command, { cwd }, (error, stdout, stderr) => {
if (error) return reject(new Error(stderr)); if (error) return reject(error.code ? new Error(stderr) : error);
resolve(stdout); resolve(stdout);
}); });
if (stdout) child.stdout.pipe(stdout); if (stdout) child.stdout.pipe(stdout);
...@@ -13,4 +13,4 @@ const execute = (command, cwd, { stdout = process.stdout, stderr = process.stder ...@@ -13,4 +13,4 @@ const execute = (command, cwd, { stdout = process.stdout, stderr = process.stder
export { export {
execute, execute,
}; };
\ No newline at end of file
...@@ -29,13 +29,9 @@ const trace = lang => (req, res, next) => { ...@@ -29,13 +29,9 @@ const trace = lang => (req, res, next) => {
const tempPath = getCodesPath(uuid.v4()); const tempPath = getCodesPath(uuid.v4());
fs.outputFile(path.resolve(tempPath, `Main.${lang}`), code) fs.outputFile(path.resolve(tempPath, `Main.${lang}`), code)
.then(() => execute(`LANG=${lang} TEMP_PATH=${tempPath} ./bin/compile`, repoPath, { stdout: null, stderr: null }) .then(() => execute(`LANG=${lang} TEMP_PATH=${tempPath} ./bin/compile`, repoPath, { stdout: null, stderr: null })
.catch(error => { .catch(error => Promise.reject(new CompileError(error.message))))
throw new CompileError(error);
}))
.then(() => execute(`LANG=${lang} TEMP_PATH=${tempPath} ./bin/run`, repoPath, { stdout: null, stderr: null }) .then(() => execute(`LANG=${lang} TEMP_PATH=${tempPath} ./bin/run`, repoPath, { stdout: null, stderr: null })
.catch(error => { .catch(error => Promise.reject(new RuntimeError(error.message))))
throw new RuntimeError(error);
}))
.then(() => res.sendFile(path.resolve(tempPath, 'traces.json'))) .then(() => res.sendFile(path.resolve(tempPath, 'traces.json')))
.catch(next) .catch(next)
.finally(() => fs.remove(tempPath)); .finally(() => fs.remove(tempPath));
...@@ -51,4 +47,4 @@ router.route('/java') ...@@ -51,4 +47,4 @@ router.route('/java')
router.route('/cpp') router.route('/cpp')
.post(trace('cpp')); .post(trace('cpp'));
export default router; export default router;
\ No newline at end of file
$font-family-normal: 'Roboto', sans-serif;
$font-family-monospace: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
\ No newline at end of file
@import "colors"; @import "colors";
@import "dimensions"; @import "dimensions";
\ No newline at end of file @import "fonts";
\ No newline at end of file
...@@ -10,7 +10,7 @@ body { ...@@ -10,7 +10,7 @@ body {
} }
body { body {
font-family: 'Roboto', sans-serif; font-family: $font-family-normal;
-webkit-font-smoothing: subpixel-antialiased; -webkit-font-smoothing: subpixel-antialiased;
user-select: none; user-select: none;
color: $color-font; color: $color-font;
......
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
border-radius: 4px; border-radius: 4px;
padding: 16px; padding: 16px;
margin: 8px; margin: 8px;
font-size: $font-size-large; white-space: pre-wrap;
white-space: pre-line;
pointer-events: auto; pointer-events: auto;
font-family: $font-family-monospace;
&.success { &.success {
border-color: rgb(0, 150, 0); border-color: rgb(0, 150, 0);
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
overflow-y: auto; overflow-y: auto;
font-family: $font-family-monospace;
.message { .message {
margin: 2px 0; margin: 2px 0;
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
font-family: 'Roboto Mono', monospace;
&:first-child { &:first-child {
border-top: none; border-top: none;
...@@ -17,9 +16,9 @@ ...@@ -17,9 +16,9 @@
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
background-color: $color-shadow; background-color: $theme-light;
color: $color-font; color: $color-font;
padding: 4px; padding: 4px 6px;
font-size: $font-size-large; font-size: $font-size-large;
} }
} }
\ No newline at end of file
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<meta name="theme-color" content="#393939"> <meta name="theme-color" content="#393939">
<link rel="shortcut icon" href="/favicon.png" type="image/png"> <link rel="shortcut icon" href="/favicon.png" type="image/png">
<link rel="manifest" href="/manifest.json"> <link rel="manifest" href="/manifest.json">
<link href="https://fonts.googleapis.com/css?family=Roboto+Mono:400,700|Roboto:400,700" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto:400,700" rel="stylesheet">
</head> </head>
<body> <body>
<div id="root" style="height: 100%"></div> <div id="root" style="height: 100%"></div>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册