style: prettier

This commit is contained in:
Gregor Martynus 2021-01-25 13:48:03 -08:00
parent ece7275743
commit a7f008253c

View File

@ -1,14 +1,14 @@
const Docker = require("dockerode");
const getStream = require("get-stream");
const pRetry = require("p-retry");
const { initBareRepo, gitShallowClone } = require("./git-utils");
const Docker = require('dockerode');
const getStream = require('get-stream');
const pRetry = require('p-retry');
const {initBareRepo, gitShallowClone} = require('./git-utils');
const IMAGE = "pvdlg/docker-gitbox:latest";
const IMAGE = 'pvdlg/docker-gitbox:latest';
const SERVER_PORT = 80;
const HOST_PORT = 2080;
const SERVER_HOST = "localhost";
const GIT_USERNAME = "integration";
const GIT_PASSWORD = "suchsecure";
const SERVER_HOST = 'localhost';
const GIT_USERNAME = 'integration';
const GIT_PASSWORD = 'suchsecure';
const docker = new Docker();
let container;
@ -23,12 +23,12 @@ async function start() {
container = await docker.createContainer({
Tty: true,
Image: IMAGE,
PortBindings: { [`${SERVER_PORT}/tcp`]: [{ HostPort: `${HOST_PORT}` }] },
PortBindings: {[`${SERVER_PORT}/tcp`]: [{HostPort: `${HOST_PORT}`}]},
});
await container.start();
const exec = await container.exec({
Cmd: ["ng-auth", "-u", GIT_USERNAME, "-p", GIT_PASSWORD],
Cmd: ['ng-auth', '-u', GIT_USERNAME, '-p', GIT_PASSWORD],
AttachStdout: true,
AttachStderr: true,
});
@ -51,9 +51,9 @@ async function stop() {
* @param {String} [description=`Repository ${name}`] The repository description.
* @return {Object} The `repositoryUrl` (URL without auth) and `authUrl` (URL with auth).
*/
async function createRepo(name, branch = "master", description = `Repository ${name}`) {
async function createRepo(name, branch = 'master', description = `Repository ${name}`) {
const exec = await container.exec({
Cmd: ["repo-admin", "-n", name, "-d", description],
Cmd: ['repo-admin', '-n', name, '-d', description],
AttachStdout: true,
AttachStderr: true,
});
@ -63,10 +63,10 @@ async function createRepo(name, branch = "master", description = `Repository ${n
const authUrl = `http://${gitCredential}@${SERVER_HOST}:${HOST_PORT}/git/${name}.git`;
// Retry as the server might take a few ms to make the repo available push
await pRetry(() => initBareRepo(authUrl, branch), { retries: 5, minTimeout: 500, factor: 2 });
await pRetry(() => initBareRepo(authUrl, branch), {retries: 5, minTimeout: 500, factor: 2});
const cwd = await gitShallowClone(authUrl);
return { cwd, repositoryUrl, authUrl };
return {cwd, repositoryUrl, authUrl};
}
module.exports = { start, stop, gitCredential, createRepo };
module.exports = {start, stop, gitCredential, createRepo};