diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e484d0c6..d60fcbc03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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][] diff --git a/package.json b/package.json index 62b163f1c..f570c9b45 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/scripts/update_flow_types.js b/scripts/update_flow_types.js new file mode 100644 index 000000000..373cb83c8 --- /dev/null +++ b/scripts/update_flow_types.js @@ -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)