@@ -47,6 +47,8 @@ const githubToken = process.env.GITHUB_TOKEN;
47
47
48
48
const altPkgRootFolder = configOptions . altPkgRootFolder ;
49
49
50
+ const skipBuildStep = configOptions . skipBuildStep ;
51
+
50
52
//------------------------------------------------------------------------------
51
53
// command line options
52
54
const yargsConf = yargs
@@ -151,6 +153,18 @@ function getOwnerAndRepo(url) {
151
153
return ( gitUrlBase || url ) . split ( '/' ) ;
152
154
}
153
155
156
+ function runAndGitRevertOnError ( cmd ) {
157
+ const res = exec ( cmd ) ;
158
+ if ( res . code !== 0 ) {
159
+ // if error, then revert and exit
160
+ console . log ( `"${ cmd } " command failed, reverting version bump` . red ) ;
161
+ run ( 'git reset HEAD .' ) ;
162
+ run ( 'git checkout package.json' ) ;
163
+ console . log ( 'Version bump reverted' . red ) ;
164
+ printErrorAndExit ( res . output ) ;
165
+ }
166
+ }
167
+
154
168
function releaseAdRepo ( repo , srcFolder , tmpFolder , vVersion ) {
155
169
if ( ! repo || ! srcFolder || ! tmpFolder || ! vVersion ) {
156
170
printErrorAndExit ( 'Bug error. Create github issue: releaseAdRepo - One of parameters is not set.' ) ;
@@ -188,11 +202,6 @@ function release({ type, preid, npmTagName }) {
188
202
}
189
203
console . info ( 'Current with latest changes from remote' . cyan ) ;
190
204
191
- // check linting and tests
192
- console . log ( 'Running: ' . cyan + 'linting and tests' . green ) ;
193
- run ( 'npm run test' ) ;
194
- console . log ( 'Completed: ' . cyan + 'linting and tests' . green ) ;
195
-
196
205
// version bump
197
206
const oldVersion = npmjson . version ;
198
207
let newVersion ;
@@ -215,21 +224,22 @@ function release({ type, preid, npmTagName }) {
215
224
console . log ( 'Version changed from ' . cyan + oldVersion . green + ' to ' . cyan + newVersion . green ) ;
216
225
safeRun ( 'git add package.json' ) ;
217
226
227
+ // npm run test
228
+ // this step is placed after version bumping
229
+ // for the case when documents are been built in "npm run test" script
230
+ console . log ( 'Running: ' . cyan + '"npm run test"' . green ) ;
231
+ config . silent = ! skipBuildStep ;
232
+ runAndGitRevertOnError ( 'npm run test' ) ;
233
+ config . silent = ! argv . verbose ;
234
+ console . log ( 'Completed: ' . cyan + '"npm run test"' . green ) ;
235
+
218
236
// npm run build
219
- if ( npmjson . scripts . build ) {
237
+ if ( npmjson . scripts . build && ! skipBuildStep ) {
220
238
console . log ( 'Running: ' . cyan + 'build' . green ) ;
221
- const res = exec ( 'npm run build' ) ;
222
- if ( res . code !== 0 ) {
223
- // if error, then revert and exit
224
- console . log ( 'Build failed, reverting version bump' . red ) ;
225
- run ( 'git reset HEAD .' ) ;
226
- run ( 'git checkout package.json' ) ;
227
- console . log ( 'Version bump reverted' . red ) ;
228
- printErrorAndExit ( res . output ) ;
229
- }
239
+ runAndGitRevertOnError ( 'npm run build' ) ;
230
240
console . log ( 'Completed: ' . cyan + 'build' . green ) ;
231
241
} else {
232
- console . log ( 'There is no " build" script in package.json. Skipping this step.' . yellow ) ;
242
+ console . log ( 'Skipping "npm run build" step.' . yellow ) ;
233
243
}
234
244
235
245
const vVersion = `v${ newVersion } ` ;
0 commit comments