Skip to content

Commit

Permalink
Cleanup type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
harveysanders committed Jan 31, 2024
1 parent 4421808 commit 91a32f6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Ci
on: [push, pull_request, workflow_dispatch]
on: [pull_request, workflow_dispatch]
jobs:
build:
runs-on: ubuntu-latest
Expand Down
13 changes: 9 additions & 4 deletions controller/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports.execAsync = function execAsync(cmd) {
return new Promise((res, rej) => {
exec(cmd, (err, stdout, stderr) => {
if (err) return rej(err);
return res(stdout, stderr);
return res({ stdout, stderr });
});
});
};
Expand All @@ -27,7 +27,12 @@ module.exports.createGithubToken = function (username, password, note) {
return `curl -u "${username}:${password}" -d '{"scopes":["public_repo", "repo", "gist"],"note":"${note}","note_url":"https://www.npmjs.com/package/opspark"}' https://api.github.com/authorizations`;
};

module.exports.deleteGithubToken = function (username, password, userAgent, authID) {
module.exports.deleteGithubToken = function (
username,
password,
userAgent,
authID
) {
return `curl -X "DELETE" -u "${username}:${password}" -A "${userAgent}" -H "Accept: application/json" https://api.github.com/authorizations/${authID}`;
};

Expand Down Expand Up @@ -63,11 +68,11 @@ module.exports.readGistHelper = function (url) {
return `curl ${url}`;
};

module.exports.installProjectDependenciesCmd = function(directory) {
module.exports.installProjectDependenciesCmd = function (directory) {
return `npm install --prefix ${directory} --loglevel=error`;
};

module.exports.removeProjectTestsCmd = function(directory) {
module.exports.removeProjectTestsCmd = function (directory) {
return `rm -rf ${directory}/test`;
};

Expand Down
2 changes: 1 addition & 1 deletion controller/shelve.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const sessions = require('./sessions');

module.exports = function () {
console.log(clc.blue('Beginning shelve process!'));
projects.action = 'shelve';
projects.action = () => 'shelve';
github
.getCredentials()
.catch(janitor.error(clc.red('Failure getting credentials')))
Expand Down
21 changes: 12 additions & 9 deletions controller/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const projectsDirectory = `${rootDirectory}/projects`;
// that user wants to be tested
function test() {
console.log(clc.blue('Beginning test process!'));
projects.action = 'test';
projects.action = () => 'test';
github
.getCredentials()
.catch(janitor.error(clc.red('Failure getting credentials')))
Expand All @@ -62,10 +62,13 @@ function test() {
}

module.exports.test = test;

// Runs svn export to download the tests for the specific project
// and places them in the correct directory
// Then calls setEnv
/**
* Runs svn export to download the tests for the specific project
* and places them in the correct directory
* Then calls setEnv
* @param {*} project
* @returns Promise<object>
*/
function grabTests(project) {
return new Promise(function (res, rej) {
const name = changeCase.paramCase(project.name);
Expand Down Expand Up @@ -168,15 +171,15 @@ function displayResults({ testResults }) {
console.log(clc.xterm(252)(`> > > ${stackLineTwo}`));
});

//part divided by the whole 3/4 = 75%
//use math.round to round to the nearest whole percent
let grade = Math.round(
// part divided by the whole 3/4 = 75%
// use math.round to round to the nearest whole percent
const grade = Math.round(
100 * (testResults.stats.passes / testResults.stats.tests)
);
const clcMethod = grade > 75 ? clc.yellow : clc.red;
console.log(clcMethod(`You have passed ${grade}% of the test.`));

return { pass: false, grade: grade };
return { pass: false, grade };
}

console.log(
Expand Down

0 comments on commit 91a32f6

Please sign in to comment.