/* global danger, fail, warn, message */

// requires
const junit = require('@seadub/danger-plugin-junit').default;
const dependencies = require('@seadub/danger-plugin-dependencies').default;
const ENV = process.env;

// Add links to artifacts we've stuffed into the ENV.ARTIFACTS variable
async function linkToArtifacts() {
	if (ENV.BUILD_STATUS === 'SUCCESS' || ENV.BUILD_STATUS === 'UNSTABLE') {
		const artifacts = ENV.ARTIFACTS.split(';');
		if (artifacts.length !== 0) {
			const artifactsListing = '- ' + artifacts.map(a => danger.utils.href(`${ENV.BUILD_URL}artifact/${a}`, a)).join('\n- ');
			message(`:floppy_disk: Here are the artifacts produced:\n${artifactsListing}`);
		}
	}
}

async function main() {
	// do a bunch of things in parallel
	// Specifically, anything that collects what labels to add or remove has to be done first before...
	await Promise.all([
		junit({ pathToReport: './TESTS-*.xml' }),
		dependencies({ type: 'npm' }),
		linkToArtifacts(),
	]);
}
main()
	.then(() => process.exit(0))
	.catch(err => {
		fail(err.toString());
		process.exit(1);
	});

@@ -181,24 +181,80 @@
 ').default;%0A
+const fs = require('fs');%0Aconst path = require('path');%0A
 const ENV = 
@@ -266,16 +266,16 @@
 ss.env;%0A
-
 %0A// Add 
@@ -377,16 +377,34 @@
 () %7B%0A%09if
+ (ENV.ARTIFACTS &&
  (ENV.BU
@@ -463,16 +463,17 @@
 STABLE')
+)
  %7B%0A%09%09con
@@ -761,16 +761,356 @@
 %7D%0A%09%7D%0A%7D%0A%0A
+async function checkLintLog() %7B%0A%09const lintLog = path.join(__dirname, 'lint.log');%0A%09if (!fs.existsSync(lintLog)) %7B%0A%09%09return;%0A%09%7D%0A%09const contents = fs.readFileSync(lintLog, 'utf8');%0A%09fail('%60npm run lint%60 failed, please check messages below for output.');%0A%09message(%60:bomb: Here's the output of %5C%60npm run lint%5C%60:%5Cn%5C%60%5C%60%5C%60$%7Bcontents%7D%5C%60%5C%60%5C%60%60);%0A%7D%0A%0A
 async fu
@@ -1361,16 +1361,16 @@
 pm' %7D),%0A
-
 %09%09linkTo
@@ -1382,16 +1382,34 @@
 acts(),%0A
+%09%09checkLintLog(),%0A
 %09%5D);%0A%7D%0Am

check for npm run lint log