-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b85497d
commit 5f8dab7
Showing
4 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules/ | ||
lib/ | ||
/scripts/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const Git = require('simple-git').default; | ||
|
||
const pkg = require('../package.json'); | ||
|
||
const git = Git(); | ||
|
||
const remoteName = 'origin'; | ||
const mainBranch = 'main'; | ||
|
||
const run = async () => { | ||
let errorMsg = ''; | ||
try { | ||
await git.addRemote(remoteName, pkg.repository.url); | ||
} catch (error) { | ||
errorMsg === error.message; | ||
} | ||
|
||
if (errorMsg && errorMsg !== 'error: remote origin already exists.') { | ||
throw new Error(errorMsg); | ||
} | ||
|
||
await git.checkout(`${remoteName}/${mainBranch}`); | ||
const remoteLog = await git.log(); | ||
const remoteHead = remoteLog.latest.hash; | ||
await git.checkout(mainBranch); | ||
const localLog = await git.log(); | ||
const localHead = localLog.latest.hash; | ||
|
||
// update done. | ||
if (localHead !== remoteHead) { | ||
await git.push(remoteName, mainBranch); | ||
} | ||
|
||
// git tag release && git push origin tag release && git tag -d release | ||
|
||
await git.addTag('release'); | ||
await git.push(remoteName, mainBranch, ['tag', 'release']); | ||
// await git.tag | ||
|
||
// const res = await git.diff(); | ||
|
||
// console.log(res); | ||
}; | ||
|
||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters