Skip to content
This repository has been archived by the owner on May 5, 2024. It is now read-only.

Commit

Permalink
🐛 Fixed bug in folder name
Browse files Browse the repository at this point in the history
  • Loading branch information
davidahouse committed Oct 25, 2019
1 parent e1bb923 commit ac72984
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions lib/workingDirectory.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
const fs = require('fs');
const chalk = require('chalk');
const { exec } = require('child_process');
"use strict";
const fs = require("fs");
const chalk = require("chalk");
const { exec } = require("child_process");

/**
* prepare the working directory
Expand All @@ -11,51 +11,51 @@ const { exec } = require('child_process');
async function prepareWorkingDirectory(taskExecutionConfig, conf) {
const today = new Date();
const todayFolder =
today.getMonth().toString() +
'-' +
today.getDay().toString() +
'-' +
(today.getMonth() + 1).toString() +
"-" +
today.getDate().toString() +
"-" +
today.getFullYear().toString();
const dir =
conf.workspaceRoot +
'/' +
"/" +
todayFolder +
'/' +
"/" +
taskExecutionConfig.task.owner +
'-' +
"-" +
taskExecutionConfig.task.repository +
'/' +
"/" +
taskExecutionConfig.task.buildKey +
'/' +
"/" +
taskExecutionConfig.task.buildNumber.toString() +
'/' +
"/" +
taskExecutionConfig.task.task.id +
'-' +
"-" +
taskExecutionConfig.task.task.number;

if (!fs.existsSync(dir)) {
const mkdirResult = await mkdir(dir);
if (!mkdirResult) {
console.log(chalk.red('Error making the directory, unable to continue!'));
console.log(chalk.red("Error making the directory, unable to continue!"));
return null;
}
}
console.log('--- working directory: ' + dir);
console.log("--- working directory: " + dir);

if (
taskExecutionConfig.gitClone === 'ssh' ||
taskExecutionConfig.gitClone === 'https'
taskExecutionConfig.gitClone === "ssh" ||
taskExecutionConfig.gitClone === "https"
) {
// Do a clone into our working directory
console.log(chalk.green('--- performing a git clone from:'));
if (taskExecutionConfig.gitClone === 'ssh') {
console.log(chalk.green("--- performing a git clone from:"));
if (taskExecutionConfig.gitClone === "ssh") {
console.log(chalk.green(taskExecutionConfig.task.scm.sshURL));
await cloneRepo(
taskExecutionConfig.task.scm.sshURL,
dir,
taskExecutionConfig.gitCloneOptions
);
} else if (conf.gitClone === 'https') {
} else if (conf.gitClone === "https") {
console.log(chalk.green(taskExecutionConfig.task.scm.cloneURL));
await cloneRepo(
taskExecutionConfig.task.scm.cloneURL,
Expand All @@ -67,27 +67,27 @@ async function prepareWorkingDirectory(taskExecutionConfig, conf) {
// Handle pull requests differently
if (taskExecutionConfig.task.scm.pullRequest != null) {
// Now checkout our head sha
console.log(chalk.green('--- head'));
console.log(chalk.green("--- head"));
console.dir(taskExecutionConfig.task.scm.pullRequest.head);
await gitCheckout(taskExecutionConfig.task.scm.pullRequest.head.sha, dir);
// And then merge the base sha
console.log(chalk.green('--- base'));
console.log(chalk.green("--- base"));
console.dir(taskExecutionConfig.task.scm.pullRequest.base);
await gitMerge(taskExecutionConfig.task.scm.pullRequest.base.sha, dir);
// Fail if we have merge conflicts
} else if (taskExecutionConfig.task.scm.branch != null) {
console.log(chalk.green('--- sha'));
console.log(chalk.green("--- sha"));
console.dir(taskExecutionConfig.task.scm.branch.sha);
await gitCheckout(taskExecutionConfig.task.scm.branch.sha, dir);
} else if (taskExecutionConfig.task.scm.release != null) {
console.log(chalk.green('--- sha'));
console.log(chalk.green("--- sha"));
console.dir(taskExecutionConfig.task.scm.release.sha);
await gitCheckout(taskExecutionConfig.task.scm.release.sha, dir);
}
} else {
console.log(
chalk.green(
'--- skipping git clone as gitClone config was not ssh or https'
"--- skipping git clone as gitClone config was not ssh or https"
)
);
}
Expand All @@ -102,7 +102,7 @@ async function prepareWorkingDirectory(taskExecutionConfig, conf) {
async function cloneRepo(cloneUrl, workingDirectory, cloneOptions) {
return new Promise(resolve => {
exec(
'git clone ' + cloneOptions + ' ' + cloneUrl + ' ' + workingDirectory,
"git clone " + cloneOptions + " " + cloneUrl + " " + workingDirectory,
(error, stdout, stderr) => {
if (error) {
console.error(`cloneRepo error: ${error}`);
Expand All @@ -126,7 +126,7 @@ async function cloneRepo(cloneUrl, workingDirectory, cloneOptions) {
async function gitCheckout(sha, workingDirectory) {
return new Promise(resolve => {
exec(
'git checkout -f ' + sha,
"git checkout -f " + sha,
{ cwd: workingDirectory },
(error, stdout, stderr) => {
if (error) {
Expand All @@ -151,7 +151,7 @@ async function gitCheckout(sha, workingDirectory) {
async function gitMerge(sha, workingDirectory) {
return new Promise(resolve => {
exec(
'git merge ' + sha,
"git merge " + sha,
{ cwd: workingDirectory },
(error, stdout, stderr) => {
if (error) {
Expand All @@ -170,7 +170,7 @@ async function gitMerge(sha, workingDirectory) {

async function mkdir(dir) {
return new Promise(resolve => {
exec('mkdir -p ' + dir, (error, stdout, stderr) => {
exec("mkdir -p " + dir, (error, stdout, stderr) => {
if (error) {
console.error(`mkdir error: ${error}`);
resolve(false);
Expand Down

0 comments on commit ac72984

Please sign in to comment.