提交 6cf9434f 编写于 作者: J Jason Park

Quiet tracers

上级 4c39148e
...@@ -4,8 +4,8 @@ import path from 'path'; ...@@ -4,8 +4,8 @@ import path from 'path';
import fs from 'fs-extra'; import fs from 'fs-extra';
import removeMarkdown from 'remove-markdown'; import removeMarkdown from 'remove-markdown';
const execute = (command, cwd, { stdout = process.stdout, stderr = process.stderr } = {}) => new Promise((resolve, reject) => { const execute = (command, { stdout = process.stdout, stderr = process.stderr, ...options } = {}) => new Promise((resolve, reject) => {
const child = child_process.exec(command, { cwd }, (error, stdout, stderr) => { const child = child_process.exec(command, options, (error, stdout, stderr) => {
if (error) return reject(error.code ? new Error(stderr) : error); if (error) return reject(error.code ? new Error(stderr) : error);
resolve(stdout); resolve(stdout);
}); });
......
...@@ -9,8 +9,8 @@ const router = express.Router(); ...@@ -9,8 +9,8 @@ const router = express.Router();
const downloadCategories = () => ( const downloadCategories = () => (
fs.pathExistsSync(hierarchy.path) ? fs.pathExistsSync(hierarchy.path) ?
execute(`git fetch && git reset --hard origin/master`, hierarchy.path) : execute(`git fetch && git reset --hard origin/master`, { cwd: hierarchy.path }) :
execute(`git clone https://github.com/algorithm-visualizer/algorithms.git ${hierarchy.path}`, __dirname) execute(`git clone https://github.com/algorithm-visualizer/algorithms.git ${hierarchy.path}`)
).then(() => hierarchy.refresh()); ).then(() => hierarchy.refresh());
downloadCategories().catch(console.error); downloadCategories().catch(console.error);
......
...@@ -32,7 +32,7 @@ const trace = lang => (req, res, next) => { ...@@ -32,7 +32,7 @@ const trace = lang => (req, res, next) => {
`-m=${memoryLimit}m`, `-m=${memoryLimit}m`,
'-e ALGORITHM_VISUALIZER=1', '-e ALGORITHM_VISUALIZER=1',
builder.imageName, builder.imageName,
].join(' ')).catch(error => { ].join(' '), { stdout: null, stderr: null }).catch(error => {
if (killed) throw new Error('Time Limit Exceeded'); if (killed) throw new Error('Time Limit Exceeded');
throw error; throw error;
}).finally(() => clearTimeout(timer)); }).finally(() => clearTimeout(timer));
......
...@@ -40,19 +40,20 @@ class Hierarchy { ...@@ -40,19 +40,20 @@ class Hierarchy {
cacheContributors(files, commitAuthors) { cacheContributors(files, commitAuthors) {
return Promise.each(files, file => { return Promise.each(files, file => {
return execute(`git --no-pager log --follow --no-merges --format="%H" "${file.path}"`, this.path, { stdout: null }) return execute(`git --no-pager log --follow --no-merges --format="%H" "${file.path}"`, {
.then(stdout => { cwd: this.path, stdout: null,
const output = stdout.toString().replace(/\n$/, ''); }).then(stdout => {
const shas = output.split('\n').reverse(); const output = stdout.toString().replace(/\n$/, '');
const contributors = []; const shas = output.split('\n').reverse();
for (const sha of shas) { const contributors = [];
const author = commitAuthors[sha]; for (const sha of shas) {
if (author && !contributors.find(contributor => contributor.login === author.login)) { const author = commitAuthors[sha];
contributors.push(author); if (author && !contributors.find(contributor => contributor.login === author.login)) {
} contributors.push(author);
} }
file.contributors = contributors; }
}); file.contributors = contributors;
});
}); });
} }
......
...@@ -12,7 +12,7 @@ class ImageBuilder { ...@@ -12,7 +12,7 @@ class ImageBuilder {
build(release) { build(release) {
const { tag_name } = release; const { tag_name } = release;
return execute(`docker build -t ${this.imageName} . --build-arg tag_name=${tag_name}`, this.directory); return execute(`docker build -t ${this.imageName} . --build-arg tag_name=${tag_name}`, { cwd: this.directory });
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册