|
2 | 2 | // See LICENSE in the project root for license information. |
3 | 3 |
|
4 | 4 | import * as semver from 'semver'; |
5 | | -import { IPackageJson } from '@microsoft/node-core-library'; |
| 5 | +import { |
| 6 | + IPackageJson, |
| 7 | + FileConstants |
| 8 | +} from '@microsoft/node-core-library'; |
6 | 9 | import { |
7 | 10 | CommandLineFlagParameter, |
8 | 11 | CommandLineStringParameter |
@@ -90,42 +93,34 @@ export class VersionAction extends BaseRushAction { |
90 | 93 | } |
91 | 94 |
|
92 | 95 | protected run(): Promise<void> { |
93 | | - // try to get the user email |
94 | | - const userEmail: string | undefined = GitPolicy.getUserEmail(this.rushConfiguration); |
95 | | - |
96 | | - if (!userEmail) { |
97 | | - return Promise.reject(undefined); |
98 | | - } |
| 96 | + return Promise.resolve().then(() => { |
| 97 | + const userEmail: string = GitPolicy.getUserEmail(this.rushConfiguration, this._bypassPolicy.value); |
99 | 98 |
|
100 | | - if (!this._bypassPolicy.value) { |
101 | | - if (!GitPolicy.check(this.rushConfiguration, userEmail)) { |
102 | | - return Promise.reject(undefined); |
103 | | - } |
104 | | - } |
105 | | - this._validateInput(); |
| 99 | + this._validateInput(); |
106 | 100 |
|
107 | | - this._versionManager = new VersionManager(this.rushConfiguration, userEmail); |
| 101 | + this._versionManager = new VersionManager(this.rushConfiguration, userEmail); |
108 | 102 |
|
109 | | - if (this._ensureVersionPolicy.value) { |
110 | | - this._overwritePolicyVersionIfNeeded(); |
111 | | - const tempBranch: string = 'version/ensure-' + new Date().getTime(); |
112 | | - this._versionManager.ensure(this._versionPolicy.value, true, |
113 | | - !!this._overrideVersion.value || !!this._prereleaseIdentifier.value); |
| 103 | + if (this._ensureVersionPolicy.value) { |
| 104 | + this._overwritePolicyVersionIfNeeded(); |
| 105 | + const tempBranch: string = 'version/ensure-' + new Date().getTime(); |
| 106 | + this._versionManager.ensure(this._versionPolicy.value, true, |
| 107 | + !!this._overrideVersion.value || !!this._prereleaseIdentifier.value); |
114 | 108 |
|
115 | | - const updatedPackages: Map<string, IPackageJson> = this._versionManager.updatedProjects; |
116 | | - if (updatedPackages.size > 0) { |
117 | | - console.log(`${updatedPackages.size} packages are getting updated.`); |
| 109 | + const updatedPackages: Map<string, IPackageJson> = this._versionManager.updatedProjects; |
| 110 | + if (updatedPackages.size > 0) { |
| 111 | + console.log(`${updatedPackages.size} packages are getting updated.`); |
| 112 | + this._gitProcess(tempBranch); |
| 113 | + } |
| 114 | + } else if (this._bumpVersion.value) { |
| 115 | + const tempBranch: string = 'version/bump-' + new Date().getTime(); |
| 116 | + this._versionManager.bump(this._versionPolicy.value, |
| 117 | + this._overwriteBump.value ? BumpType[this._overwriteBump.value] : undefined, |
| 118 | + this._prereleaseIdentifier.value, |
| 119 | + true); |
118 | 120 | this._gitProcess(tempBranch); |
119 | 121 | } |
120 | | - } else if (this._bumpVersion.value) { |
121 | | - const tempBranch: string = 'version/bump-' + new Date().getTime(); |
122 | | - this._versionManager.bump(this._versionPolicy.value, |
123 | | - this._overwriteBump.value ? BumpType[this._overwriteBump.value] : undefined, |
124 | | - this._prereleaseIdentifier.value, |
125 | | - true); |
126 | | - this._gitProcess(tempBranch); |
127 | | - } |
128 | | - return Promise.resolve(); |
| 122 | + return Promise.resolve(); |
| 123 | + }); |
129 | 124 | } |
130 | 125 |
|
131 | 126 | private _overwritePolicyVersionIfNeeded(): void { |
@@ -220,7 +215,7 @@ export class VersionAction extends BaseRushAction { |
220 | 215 |
|
221 | 216 | // Commit the package.json and change files updates. |
222 | 217 | const packageJsonUpdated: boolean = uncommittedChanges.some((changePath) => { |
223 | | - return changePath.indexOf('package.json') > 0; |
| 218 | + return changePath.indexOf(FileConstants.PackageJson) > 0; |
224 | 219 | }); |
225 | 220 |
|
226 | 221 | if (packageJsonUpdated) { |
|
0 commit comments