Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add check to determine if we need to pop from git stash #7

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 24 additions & 16 deletions .scripts/update-icon-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const simpleGit = require('simple-git');
const path = require('path');
const { execSync } = require('node:child_process')
const fs = require('fs-extra');
const { stat } = require("fs");

const baseIconsPath = path.join(process.cwd())
const srcIconsBasePath = path.join(baseIconsPath, 'src');
Expand Down Expand Up @@ -48,22 +49,29 @@ const run = async (nextVersionType = null, preid='') => {

await git.stash(['save', '--include-untracked']);
const iconPkgVersion = await getNextVersion(nextVersionType, preid);
await git.stash(['pop']);

if (iconPkgVersion == null)
throw Error('Icon package version could not be determined')

await updateChangelogFile(iconPkgVersion)
await git.add([
srcSvgBasePath, // svgs
changelogsPath, // Changelogs
path.join(srcIconsBasePath, 'index.html'), // updated homepage with new changelog file
path.join(srcIconsBasePath, 'icon-data.json'), // icon data
])

const msg = `created: ${created.length}, modified: ${modified.length}, renamed: ${renamed.length}, deleted: ${deleted.length}`
await git.commit(`ci(icons): v${iconPkgVersion}, ${msg}`)
await git.tag([`@pine-ds/icons@${iconPkgVersion}`, '-a', '-m', msg]);

// We don't want to do anything for Icons if there were no changes
// but we still need to pass through to continue if there were values
// passed in e.g nextVersionType and preid
if (statusResults.files.length > 0) {

await git.stash(['pop']);

if (iconPkgVersion == null)
throw Error('Icon package version could not be determined')

await updateChangelogFile(iconPkgVersion)
await git.add([
srcSvgBasePath, // svgs
changelogsPath, // Changelogs
path.join(srcIconsBasePath, 'index.html'), // updated homepage with new changelog file
path.join(srcIconsBasePath, 'icon-data.json'), // icon data
])

const msg = `created: ${created.length}, modified: ${modified.length}, renamed: ${renamed.length}, deleted: ${deleted.length}`
await git.commit(`ci(icons): v${iconPkgVersion}, ${msg}`)
await git.tag([`@pine-ds/icons@${iconPkgVersion}`, '-a', '-m', msg]);
}

const output = [nextVersionType];
if (preid != '' )
Expand Down