Skip to content

Commit

Permalink
fix: stat results not showing version before update
Browse files Browse the repository at this point in the history
  • Loading branch information
jgazeau committed May 8, 2022
1 parent d1cb243 commit 4914faa
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,26 @@ Additional information:
Issues: https://github.com/jgazeau/bmyc/issues
```

### How to hold a version?

To hold a version, set the `hold` parameter for the specific asset to `true`:
```json
{
...
"name": "asset1",
"hold": true,
...
}
```

# Examples

```json
[
{
"package": "asset1Package",
"name": "asset1",
"hold": false,
"localPath": "path/asset1.min.js",
"assetManager": {
"name": "cdnjs",
Expand All @@ -69,7 +83,9 @@ Additional information:
"currentVersion": "0.0.1"
},
{
"package": "asset2Package",
"name": "asset2",
"hold": false,
"localPath": "./path/asset2.min.js",
"assetManager": {
"name": "github",
Expand Down
12 changes: 12 additions & 0 deletions src/model/configurationFile/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,17 @@ export class Asset {
}
/* c8 ignore stop */

@Exclude()
private beforeUpdateVersion?: string | undefined;
/* c8 ignore start */
public get _beforeUpdateVersion(): string | undefined {
return this.beforeUpdateVersion;
}
public set _beforeUpdateVersion(value: string | undefined) {
this.beforeUpdateVersion = value;
}
/* c8 ignore stop */

@Exclude()
private isUpdated = false;
/* c8 ignore start */
Expand Down Expand Up @@ -153,6 +164,7 @@ export class Asset {
.getLatestVersion()
.then((latestVersion: string) => {
this.latestVersion = latestVersion;
this.beforeUpdateVersion = this.currentVersion;
this.isNewVersion = latestVersion !== this.currentVersion;
if ((!this.isNewVersion && !force) || this.hold) {
return Promise.resolve(this);
Expand Down
4 changes: 3 additions & 1 deletion src/utils/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ export function getStatus(asset: Asset, error?: Error): PrintEntry {

export function getAssetVersion(asset: Asset): string {
return asset._latestVersion
? `${asset._currentVersion}\n(${asset._latestVersion})`
? asset._isUpdated || asset._hold
? `${asset._beforeUpdateVersion}\n(${asset._latestVersion})`
: asset._latestVersion
: asset._currentVersion || 'N/A';
}

Expand Down

0 comments on commit 4914faa

Please sign in to comment.