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

Quiet tracers

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