Skip to content

Commit

Permalink
pushes back to repo
Browse files Browse the repository at this point in the history
  • Loading branch information
electricgull committed Mar 7, 2023
1 parent a599507 commit f389d7c
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions yarn2npm/yarn2npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const gitHubAuthFunct = () => { return { username: process.env.GITHUB_AUTH_TOKEN

const org = 'jupiterone';
const repo = process.argv.slice(2);
const prbranch = "yarn2npm-patch1";
const prbranch = "yarn2npm-patch-1";

const tmpDir="yarn2npm_tmp";
const fs = require('fs');
Expand Down Expand Up @@ -75,7 +75,7 @@ const main = async () => {
});

//Find and replace yarn commands
onsole.log(`Replacing yarn commands with npm`);
console.log(`Replacing yarn commands with npm`);
const packageFile = fs.readFileSync(`package.json`, {
encoding: 'utf8',
flag: 'r',
Expand All @@ -86,12 +86,37 @@ const main = async () => {
if (err) return console.log(err);
});

// Check to see if changes needs to be pushed
await pushChanges(`${currentPath}/${dir}`);

return [];
} catch (e) {
console.log(`Error ${e}`);
}
}

async function pushChanges (dir) {
console.log(`Pushing changes`);
await git.commit({
fs,
dir,
author: {
name: 'J1 Security',
email: '[email protected]'
},
message: 'Updating yarn to npm'
});

await git.push({
fs,
http,
dir,
remote: 'origin',
force: true,
onAuth: gitHubAuthFunct
});
}

async function createYarn2NpmBranch (repo, dir, org, branch = prbranch) {
console.log(`Cloning Repo ${org}/${repo}...`);
await cloneRepo(repo, dir, org);
Expand Down

0 comments on commit f389d7c

Please sign in to comment.