Skip to content

Commit

Permalink
style(commands): update type definition for commands
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed Jan 4, 2017
1 parent 2d734d1 commit 155f466
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 85 deletions.
6 changes: 0 additions & 6 deletions source/commands/danger-local.js

This file was deleted.

3 changes: 3 additions & 0 deletions source/commands/danger-local.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import * as program from 'commander';

program.parse(process.argv);
8 changes: 0 additions & 8 deletions source/commands/danger-pr.js

This file was deleted.

5 changes: 5 additions & 0 deletions source/commands/danger-pr.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as program from 'commander';

program.parse(process.argv);

console.log('Not Yet implmented');
54 changes: 0 additions & 54 deletions source/commands/danger-run.js

This file was deleted.

52 changes: 52 additions & 0 deletions source/commands/danger-run.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import * as program from 'commander';
import { getCISource } from '../ci_source/get_ci_source';
import { getPlatformForEnv } from '../platforms/platform';
import {Executor} from '../runner/Executor';

declare const global: any;

program
.option('-v, --verbose', 'Verbose output of files')
.option('-c, --external-ci-provider [modulePath]', 'blah')
.parse(process.argv);

process.on('unhandledRejection', function(reason: string, _p: any) {
console.log('Error: ', reason);
process.exitCode = 1;
});

if (process.env['DANGER_VERBOSE'] || (program as any).verbose) {
global.verbose = true;
}

const source = getCISource(process.env, (program as any).externalCiProvider || undefined);

if (!source) {
console.log('Could not find a CI source for this run');
// Check for ENV["CI"] and wanr they might want a local command instead?
process.exitCode = 1;
}

if (source && !source.isPR) {
console.log('Skipping due to not being a PR');
}

if (source && source.isPR) {
const platform = getPlatformForEnv(process.env, source);
if (!platform) {
console.log(`Could not find a source code hosting platform for ${source.name}`);
process.exitCode = 1;
}

if (platform) {
console.log(`OK, looks good ${source.name} on ${platform.name}`);
try {
const exec = new Executor(source, platform);
exec.setupAndRunDanger('dangerfile.js');
} catch (error) {
process.exitCode = 1;
console.error(error.message);
console.error(error);
}
}
}
17 changes: 0 additions & 17 deletions source/commands/danger.js

This file was deleted.

14 changes: 14 additions & 0 deletions source/commands/danger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#! /usr/bin/env node

// import app from "./app"
import { version } from '../../package.json';
import * as program from 'commander';

// Provides the root node to the command-line architecture

program
.version(version)
.command('run', 'Runs danger on your local system', {isDefault: true})
.command('init', 'Creates a new Dangerfile.js')
.command('local', 'Runs your changes against ')
.parse(process.argv);

0 comments on commit 155f466

Please sign in to comment.