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

Update the flow types, and prepare for 2.0 release #419

Merged
merged 1 commit into from
Nov 4, 2017
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

// ### Master

### 2.0.0

- Fixes the `danger.js.flow` fix to handle exports correctly, you _probably_ need to add
`.*/node_modules/danger/distribution/danger.js.flow` to the `[libs]` section of your settings for it to work though - [@orta][]

### 2.0.0-beta.2

- Fixes a bug with `danger.github.utils` in that it didn't work as of b1, and now it does :+1: - [@orta][]
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "danger",
"version": "2.0.0-beta.1",
"version": "2.0.0",
"description": "Unit tests for Team Culture",
"main": "distribution/danger.js",
"typings": "distribution/danger.d.ts",
Expand Down Expand Up @@ -38,7 +38,7 @@
"prepublishOnly": "yarn run build && yarn declarations && yarn build:flow-types",
"build": "shx rm -rf ./distribution && tsc -p tsconfig.production.json && madge ./distribution --circular",
"build:flow-types":
"cp source/danger.d.ts source/_danger.d.ts; sed -ie 's/api: GitHub/api: any/g' source/_danger.d.ts; npx flowgen source/_danger.d.ts -o distribution/danger.js.flow; rm source/_danger.d.ts",
"cp source/danger.d.ts source/_danger.d.ts; sed -ie 's/api: GitHub/api: any/g' source/_danger.d.ts; npx flowgen source/_danger.d.ts -o distribution/danger.js.flow; node scripts/update_flow_types.js",
"build:watch": "tsc -w",
"link": "yarn run build && chmod +x distribution/commands/danger.js && npm link",
"declarations": "ts-node ./scripts/create-danger-dts.ts",
Expand Down
30 changes: 30 additions & 0 deletions scripts/update_flow_types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const fs = require("fs")

// kill the two generated danger dts files
if (fs.existsSync("./source/_danger.d.ts")) {
fs.unlinkSync("./source/_danger.d.ts")
}

if (fs.existsSync("./source/_danger.d.tse")) {
fs.unlinkSync("./source/_danger.d.tse")
}

const exportedLines = [
"function schedule",
"function fail",
"function warn",
"function message",
"function markdown",
"var danger",
"var results",
]

var flowDef = fs.readFileSync("distribution/danger.js.flow", "utf8")
exportedLines.forEach(line => {
// from declare function schedule
// to declare export function schedule
const find = "declare " + line
const newLine = "declare export " + line
flowDef = flowDef.replace(find, newLine)
})
fs.writeFileSync("distribution/danger.js.flow", flowDef)