How to use the danger.schedule function in danger

To help you get started, we’ve selected a few danger examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github danger / peril / api / source / danger / _tests / fixtures / dangerfile_import_complex_module.ts View on Github external
// @ts-ignore

import { schedule } from "danger"
import spellcheck from "danger-plugin-spellcheck"

schedule(spellcheck())
github Automattic / jetpack / dangerfile.js View on Github external
function setReleaseDates() {
	schedule( async () => {
		let jetpackReleaseDate;
		let codeFreezeDate;
		const milestones = await github.api.issues.listMilestonesForRepo( {
			owner: 'Automattic',
			repo: 'jetpack',
		} );

		// Find a milestone which name is a version number
		// and it's due dates is earliest in a future
		const nextMilestone = milestones.data
			.filter( m => m.title.match( /\d\.\d/ ) )
			.sort( ( m1, m2 ) => parseFloat( m1.title ) - parseFloat( m2.title ) )
			.find( milestone => milestone.due_on && moment( milestone.due_on ) > moment() );

		if ( nextMilestone ) {
			jetpackReleaseDate = moment( nextMilestone.due_on ).format( 'LL' );
github StoDevX / AAO-React-Native / dangerfile.js View on Github external
function fileLog(
	name /*: string*/,
	log /*: string*/,
	{lang = null} /*: any*/ = {},
) {
	return markdown(
		`## ${name}

${m.code({language: lang}, log)}`,
	)
}

//
// Run the file
//
schedule(main)
github withspectrum / spectrum / dangerfile.js View on Github external
// Make sure the yarn.lock file is updated when dependencies get added and log any added dependencies
APP_FOLDERS.forEach(folder => {
  schedule(yarn(path.join(__dirname, folder, 'package.json')));
});

// Log test failures if there are any
jest();

// Make sure nobody does a it.only and blocks our entire test-suite from running
noTestShortcuts({
  testFilePredicate: filePath =>
    filePath.endsWith('.test.js') || filePath.endsWith('_spec.js'),
});

schedule(noConsole({ whitelist: ['error'] }));

schedule(
  flow({
    // Fail on newly created untyped files
    created: 'fail',
    // Warn on modified untyped files
    modified: 'warn',
    blacklist: [
      'flow-typed/**/*.js',
      'public/**/*.js',
      'iris/migrations/**/*.js',
      'cypress/**/*.js',
    ],
  })
);
github Automattic / vip-go-mu-plugins-built / jetpack / dangerfile.js View on Github external
function setReleaseDates() {
	schedule( async () => {
		let jetpackReleaseDate;
		let codeFreezeDate;
		const milestones = await github.api.issues.listMilestonesForRepo( {
			owner: 'Automattic',
			repo: 'jetpack',
		} );

		// Find a milestone which name is a version number
		// and it's due dates is earliest in a future
		const nextMilestone = milestones.data
			.filter( m => m.title.match( /\d\.\d/ ) )
			.sort( ( m1, m2 ) => parseFloat( m1.title ) - parseFloat( m2.title ) )
			.find( milestone => milestone.due_on && moment( milestone.due_on ) > moment() );

		if ( nextMilestone ) {
			jetpackReleaseDate = moment( nextMilestone.due_on ).format( 'LL' );
github infinitered / solidarity / dangerfile.ts View on Github external
import { danger, warn, schedule } from 'danger'
// can't use import in JS
const spellcheck = require('danger-plugin-spellcheck').default
const JSON5 = require('json5')
const fs = require('fs')

const whitelistWords = JSON5.parse(fs.readFileSync('./.vscode/cSpell.json')).words
// let's spellcheck
schedule(
  spellcheck({
    ignore: whitelistWords.map(word => word.toLowerCase()),
    whitelistFiles: ['docs/existingContributors.md'],
  })
)

// Enforce yarn.lock updates
const packageChanged = danger.git.modified_files.includes('package.json')
const yarnLockfileChanged = danger.git.modified_files.includes('yarn.lock')
const npmLockfileChanged = danger.git.modified_files.includes('package-lock.json')
if (packageChanged && !yarnLockfileChanged) {
  const message = 'Changes were made to package.json, but not to yarn.lock'
  const idea = 'Perhaps you need to run `yarn install`?'
  warn(`${message} - <i>${idea}</i>`)
}
// // Enforce package-lock.json
github withspectrum / spectrum / dangerfile.js View on Github external
APP_FOLDERS.forEach(folder => {
  schedule(yarn(path.join(__dirname, folder, 'package.json')));
});

// Log test failures if there are any
jest();

// Make sure nobody does a it.only and blocks our entire test-suite from running
noTestShortcuts({
  testFilePredicate: filePath =>
    filePath.endsWith('.test.js') || filePath.endsWith('_spec.js'),
});

schedule(noConsole({ whitelist: ['error'] }));

schedule(
  flow({
    // Fail on newly created untyped files
    created: 'fail',
    // Warn on modified untyped files
    modified: 'warn',
    blacklist: [
      'flow-typed/**/*.js',
      'public/**/*.js',
      'iris/migrations/**/*.js',
      'cypress/**/*.js',
    ],
  })
);
github danreeves / react-tether / dangerfile.js View on Github external
// Updates to the source require changelog updates
if (modifiedSrc.length > 1 && !changelogChanges) {
  warn(`You changed a source file but didn't add to the changelog`);
}

// Pull requests should have descriptions
if (danger.github.pr.body.length === 0) {
  warn('Please add a description to your PR');
}

// You added tests :tada:
if (testChanges.length > 0) {
  message(':tada: Thanks for working on tests!');
}

schedule(istanbulCoverage());
github withspectrum / spectrum / dangerfile.js View on Github external
APP_FOLDERS.forEach(folder => {
  schedule(yarn(path.join(__dirname, folder, 'package.json')));
});