Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Case issues #29

Merged
merged 8 commits into from
Oct 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ Danger on Node, wonder what's going on? see [VISION.md](VISION.md)

### Get started?

This is like, kinda early. If you can take a bit of heat, it's usable in production as of 0.0.4.

Bah, there's something wrong with the deploy. So for now, it's not working as an imported module. [See this PR](https://github.com/artsy/emission/pull/385).
This is like, kinda early. If you can take a bit of heat, it's usable in production as of 0.0.10. Note: There is basically no error reporting ATM.

### Early Adopters

Expand All @@ -27,12 +25,12 @@ Then add a run command to your `Package.json`
"danger": "danger"
```

Then add a Dangerfile.js with some rules:
Then create a `dangerfile.js` in the project root with some rules:

```js
import { danger, fail } from "danger"

// warn on changes in Package.json and not in shrinkwrap
// Make sure there are changelog entries
const hasChangelog = danger.git.modified_files.includes("changelog.md")
if (!hasChangelog) {
fail("No Changelog changes!")
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

// Add your own contribution below

### 0.0.5-0.0.10

* Changes some files casing, added some logs, a bit of error reporting, and verifying everything works through npm - orta

### 0.0.4

* Danger edit an existing post, and delete it when it's not relevant - orta
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "danger",
"version": "0.0.4",
"version": "0.0.10",
"description": "Automate your culture",
"main": "distribution/danger.js",
"bin": {
Expand All @@ -19,6 +19,7 @@
"flow": "flow; test $? -eq 0 -o $? -eq 2",
"lint": "eslint ./source",
"fix": "eslint ./source --fix",
"prepublish": "npm run build",
"build": "babel source --out-dir distribution --source-maps",
"buildwatch": "babel source --watch --out-dir distribution",
"link": "npm run build ; chmod +x distribution/commands/danger.js ; npm link"
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion source/ci_source/_tests/_travis.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Travis from "../travis.js"
import Travis from "../Travis"

const correctEnv = {
"HAS_JOSH_K_SEAL_OF_APPROVAL": "true",
Expand Down
4 changes: 2 additions & 2 deletions source/ci_source/ci_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export interface CISource {
name: string
}

import Travis from "./travis"
import Fake from "./fake"
import Travis from "./Travis"
import Fake from "./Fake"

/**
* Gets a CI Source form the current environment, by asking all known
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion source/platforms/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export interface Platform {
// async editComment: (comment: Comment, newBody: string) => Promise<boolean>;
// }

import { GitHub } from "./github"
import { GitHub } from "./GitHub"

/**
* Pulls out a platform for Danger to communicate on based on the environment
Expand Down
16 changes: 14 additions & 2 deletions source/runner/Dangerfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,29 @@ export default class Dangerfile {
const context: any = {
fail,
console,
require,
danger: this.dsl
}

script.runInNewContext(context)
console.log("Running Script")
try {
script.runInNewContext(context)
}
catch (e) {
console.log(e.toString())
}

return results
}

readFile(path: String): Promise<string> {
return new Promise((resolve: any, reject: any) => {
fs.readFile(path, "utf8", (err: Error, data: string) => {
if (err) { return reject(err) }
if (err) {
console.error("Error: " + err.message)
process.exitCode = 1
return reject(err)
}
resolve(data)
})
})
Expand Down
3 changes: 3 additions & 0 deletions source/runner/Executor.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ export default class Executor {
async run() {
const git = await this.platform.getReviewDiff()
const pr = await this.platform.getReviewInfo()
console.log("Got github deets")

const dsl = new DangerDSL(pr, git)
const dangerfile = new Dangerfile(dsl)
const results = await dangerfile.run("dangerfile.js")
console.log("Got results")

if (results.fails.length) {
process.exitCode = 1
Expand Down