diff --git a/@commitlint/top-level/index.d.ts b/@commitlint/top-level/index.d.ts new file mode 100644 index 0000000000..f41a696fd2 --- /dev/null +++ b/@commitlint/top-level/index.d.ts @@ -0,0 +1 @@ +export * from './lib'; diff --git a/@commitlint/top-level/index.js b/@commitlint/top-level/index.js new file mode 100644 index 0000000000..bb0a047c4f --- /dev/null +++ b/@commitlint/top-level/index.js @@ -0,0 +1 @@ +module.exports = require('./lib'); diff --git a/@commitlint/top-level/package.json b/@commitlint/top-level/package.json index fb01288399..1f819162e3 100644 --- a/@commitlint/top-level/package.json +++ b/@commitlint/top-level/package.json @@ -7,11 +7,11 @@ "lib/" ], "scripts": { - "build": "cross-env NODE_ENV=production babel src --out-dir lib --source-maps", + "build": "tsc", "deps": "dep-check", "pkg": "pkg-check", "start": "yarn watch", - "watch": "babel src --out-dir lib --watch --source-maps" + "watch": "tsc -w" }, "babel": { "presets": [ @@ -42,12 +42,14 @@ "license": "MIT", "devDependencies": { "@commitlint/utils": "^8.0.0", + "@types/node": "^12.0.4", "babel-cli": "6.26.0", "babel-preset-commitlint": "^8.0.0", "babel-register": "6.26.0", - "cross-env": "5.1.1" + "cross-env": "5.1.1", + "typescript": "^3.5.1" }, "dependencies": { - "find-up": "^2.1.0" + "find-up": "^4.0.0" } } diff --git a/@commitlint/top-level/src/index.ts b/@commitlint/top-level/src/index.ts new file mode 100644 index 0000000000..94a9a7beeb --- /dev/null +++ b/@commitlint/top-level/src/index.ts @@ -0,0 +1,17 @@ +import path from 'path'; +import up from 'find-up'; + +export default toplevel; + +/** + * Find the next git root + */ +async function toplevel(cwd: string) { + const found = await up('.git', { cwd, type: 'directory' }); + + if (typeof found !== 'string') { + return found; + } + + return path.join(found, '..'); +} diff --git a/@commitlint/top-level/tsconfig.json b/@commitlint/top-level/tsconfig.json new file mode 100644 index 0000000000..cc39443b9c --- /dev/null +++ b/@commitlint/top-level/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "lib": [ + "dom", + "es2015" + ], + "rootDir": "src", + "outDir": "lib", + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true + }, + "include": [ + "./src" + ], + "exclude": [ + "./src/**/*.test.ts" + ] +} diff --git a/yarn.lock b/yarn.lock index 146b04857d..fece3db6ac 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1279,6 +1279,11 @@ resolved "https://registry.npmjs.org/@types/node/-/node-12.0.2.tgz#3452a24edf9fea138b48fad4a0a028a683da1e40" integrity sha512-5tabW/i+9mhrfEOUcLDu2xBPsHJ+X5Orqy9FKpale3SjDA17j5AEpYq5vfy3oAeAHGcvANRCO3NV3d2D6q3NiA== +"@types/node@^12.0.4": + version "12.0.8" + resolved "https://registry.npmjs.org/@types/node/-/node-12.0.8.tgz#551466be11b2adc3f3d47156758f610bd9f6b1d8" + integrity sha512-b8bbUOTwzIY3V5vDTY1fIJ+ePKDUBqt2hC2woVGotdQQhG/2Sh62HOKHrT7ab+VerXAcPyAiTEipPu/FsreUtg== + "@types/normalize-package-data@^2.4.0": version "2.4.0" resolved "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e" @@ -4749,6 +4754,13 @@ find-up@^3.0.0: dependencies: locate-path "^3.0.0" +find-up@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/find-up/-/find-up-4.0.0.tgz#c367f8024de92efb75f2d4906536d24682065c3a" + integrity sha512-zoH7ZWPkRdgwYCDVoQTzqjG8JSPANhtvLhh4KVUHyKnaUJJrNeFmWIkTcNuJmR3GLMEmGYEf2S2bjgx26JTF+Q== + dependencies: + locate-path "^5.0.0" + findup-sync@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/findup-sync/-/findup-sync-3.0.0.tgz#17b108f9ee512dfb7a5c7f3c8b27ea9e1a9c08d1" @@ -7047,6 +7059,13 @@ locate-path@^3.0.0: p-locate "^3.0.0" path-exists "^3.0.0" +locate-path@^5.0.0: + version "5.0.0" + resolved "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" + integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g== + dependencies: + p-locate "^4.1.0" + lodash._reinterpolate@~3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d" @@ -8315,6 +8334,13 @@ p-limit@^2.0.0: dependencies: p-try "^2.0.0" +p-limit@^2.2.0: + version "2.2.0" + resolved "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz#417c9941e6027a9abcba5092dd2904e255b5fbc2" + integrity sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ== + dependencies: + p-try "^2.0.0" + p-locate@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43" @@ -8329,6 +8355,13 @@ p-locate@^3.0.0: dependencies: p-limit "^2.0.0" +p-locate@^4.1.0: + version "4.1.0" + resolved "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" + integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A== + dependencies: + p-limit "^2.2.0" + p-map-series@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/p-map-series/-/p-map-series-1.0.0.tgz#bf98fe575705658a9e1351befb85ae4c1f07bdca" @@ -10705,6 +10738,11 @@ typescript@3.5.1: resolved "https://registry.npmjs.org/typescript/-/typescript-3.5.1.tgz#ba72a6a600b2158139c5dd8850f700e231464202" integrity sha512-64HkdiRv1yYZsSe4xC1WVgamNigVYjlssIoaH2HcZF0+ijsk5YK2g0G34w9wJkze8+5ow4STd22AynfO6ZYYLw== +typescript@^3.5.1: + version "3.5.2" + resolved "https://registry.npmjs.org/typescript/-/typescript-3.5.2.tgz#a09e1dc69bc9551cadf17dba10ee42cf55e5d56c" + integrity sha512-7KxJovlYhTX5RaRbUdkAXN1KUZ8PwWlTzQdHV6xNqvuFOs7+WBo10TQUqT19Q/Jz2hk5v9TQDIhyLhhJY4p5AA== + uglify-js@^3.1.4: version "3.4.9" resolved "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.9.tgz#af02f180c1207d76432e473ed24a28f4a782bae3"