From 938c4c0383ce189c54826e7539bc7568dcc15472 Mon Sep 17 00:00:00 2001 From: Timo Hocker Date: Sat, 23 May 2020 17:36:36 +0200 Subject: [PATCH] require up to date readme --- jenkins.run.js | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/jenkins.run.js b/jenkins.run.js index 3d43045..ed98f38 100644 --- a/jenkins.run.js +++ b/jenkins.run.js @@ -22,14 +22,16 @@ child_process.execSync ('yarn lint', { stdio: 'inherit' }); child_process.execSync ('yarn test', { stdio: 'inherit' }); child_process.execSync ('yarn compile', { stdio: 'inherit' }); +let ok = true; + if (typeof pkg.description === 'undefined' || pkg.description === '') { console.log ('description undefined'); - process.exit (1); + ok = false; } if (typeof pkg.repository === 'undefined') { console.log ('repository undefined'); - process.exit (1); + ok = false; } function major (version) { @@ -44,11 +46,31 @@ if (fs.existsSync ('README.md')) { || major (version[1]) !== major (pkg.version) ) { console.log ('readme version does not match package version'); - process.exit (1); + ok = false; } - else { child_process.execSync ('yarn publish --access public'); } } else { console.log ('readme does not exist'); - process.exit (1); + ok = false; } + +if (fs.existsSync ('CHANGELOG.md')) { + const changelog = fs.readFileSync ('CHANGELOG.md', 'utf-8'); + const cl_version = (/^## ([0-9x.]+)/mu).exec (changelog); + if ( + cl_version === null + || major (cl_version[1] !== major (pkg.version)) + ) { + console.log ('changelog is not up to date'); + ok = false; + } +} +else { + console.log ('changelog does not exist'); + ok = false; +} + +if (ok) + child_process.execSync ('yarn publish --access public'); +else + process.exit (1);