From ac729845a797f82d358bf6081ed23ba900f91dee Mon Sep 17 00:00:00 2001 From: David house Date: Thu, 24 Oct 2019 19:48:49 -0600 Subject: [PATCH] :bug: Fixed bug in folder name --- lib/workingDirectory.js | 62 ++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/lib/workingDirectory.js b/lib/workingDirectory.js index f155f31..e09f883 100644 --- a/lib/workingDirectory.js +++ b/lib/workingDirectory.js @@ -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 @@ -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, @@ -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" ) ); } @@ -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}`); @@ -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) { @@ -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) { @@ -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);