Skip to content

Commit da08e02

Browse files
committed
refactor(top-level): rewrite top level to typescript
1 parent 9075844 commit da08e02

File tree

6 files changed

+73
-8
lines changed

6 files changed

+73
-8
lines changed

@commitlint/top-level/index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './lib';

@commitlint/top-level/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./lib');

@commitlint/top-level/package.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
"lib/"
88
],
99
"scripts": {
10-
"build": "cross-env NODE_ENV=production babel src --out-dir lib --source-maps",
10+
"build": "tsc",
1111
"deps": "dep-check",
1212
"pkg": "pkg-check",
1313
"start": "yarn watch",
14-
"watch": "babel src --out-dir lib --watch --source-maps"
14+
"watch": "tsc -w"
1515
},
1616
"babel": {
1717
"presets": [
@@ -42,12 +42,14 @@
4242
"license": "MIT",
4343
"devDependencies": {
4444
"@commitlint/utils": "^8.0.0",
45+
"@types/node": "^12.0.4",
4546
"babel-cli": "6.26.0",
4647
"babel-preset-commitlint": "^8.0.0",
4748
"babel-register": "6.26.0",
48-
"cross-env": "5.1.1"
49+
"cross-env": "5.1.1",
50+
"typescript": "^3.5.1"
4951
},
5052
"dependencies": {
51-
"find-up": "^2.1.0"
53+
"find-up": "^4.0.0"
5254
}
5355
}

@commitlint/top-level/src/index.js renamed to @commitlint/top-level/src/index.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import up from 'find-up';
33

44
export default toplevel;
55

6-
// Find the next git root
7-
// (start: string) => Promise<string | null>
8-
async function toplevel(cwd) {
9-
const found = await up('.git', {cwd});
6+
/**
7+
* Find the next git root
8+
*/
9+
async function toplevel(cwd: string) {
10+
const found = await up('.git', {cwd, type: 'directory'});
1011

1112
if (typeof found !== 'string') {
1213
return found;

@commitlint/top-level/tsconfig.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"compilerOptions": {
3+
"lib": [
4+
"dom",
5+
"es2015"
6+
],
7+
"rootDir": "src",
8+
"outDir": "lib",
9+
"declaration": true,
10+
"declarationMap": true,
11+
"sourceMap": true,
12+
"esModuleInterop": true,
13+
"allowSyntheticDefaultImports": true,
14+
"strict": true
15+
},
16+
"include": [
17+
"./src"
18+
],
19+
"exclude": [
20+
"./src/**/*.test.ts"
21+
]
22+
}

yarn.lock

+38
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,11 @@
12791279
resolved "https://registry.npmjs.org/@types/node/-/node-12.0.2.tgz#3452a24edf9fea138b48fad4a0a028a683da1e40"
12801280
integrity sha512-5tabW/i+9mhrfEOUcLDu2xBPsHJ+X5Orqy9FKpale3SjDA17j5AEpYq5vfy3oAeAHGcvANRCO3NV3d2D6q3NiA==
12811281

1282+
"@types/node@^12.0.4":
1283+
version "12.0.8"
1284+
resolved "https://registry.npmjs.org/@types/node/-/node-12.0.8.tgz#551466be11b2adc3f3d47156758f610bd9f6b1d8"
1285+
integrity sha512-b8bbUOTwzIY3V5vDTY1fIJ+ePKDUBqt2hC2woVGotdQQhG/2Sh62HOKHrT7ab+VerXAcPyAiTEipPu/FsreUtg==
1286+
12821287
"@types/normalize-package-data@^2.4.0":
12831288
version "2.4.0"
12841289
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:
47494754
dependencies:
47504755
locate-path "^3.0.0"
47514756

4757+
find-up@^4.0.0:
4758+
version "4.0.0"
4759+
resolved "https://registry.npmjs.org/find-up/-/find-up-4.0.0.tgz#c367f8024de92efb75f2d4906536d24682065c3a"
4760+
integrity sha512-zoH7ZWPkRdgwYCDVoQTzqjG8JSPANhtvLhh4KVUHyKnaUJJrNeFmWIkTcNuJmR3GLMEmGYEf2S2bjgx26JTF+Q==
4761+
dependencies:
4762+
locate-path "^5.0.0"
4763+
47524764
findup-sync@^3.0.0:
47534765
version "3.0.0"
47544766
resolved "https://registry.npmjs.org/findup-sync/-/findup-sync-3.0.0.tgz#17b108f9ee512dfb7a5c7f3c8b27ea9e1a9c08d1"
@@ -7047,6 +7059,13 @@ locate-path@^3.0.0:
70477059
p-locate "^3.0.0"
70487060
path-exists "^3.0.0"
70497061

7062+
locate-path@^5.0.0:
7063+
version "5.0.0"
7064+
resolved "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0"
7065+
integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==
7066+
dependencies:
7067+
p-locate "^4.1.0"
7068+
70507069
lodash._reinterpolate@~3.0.0:
70517070
version "3.0.0"
70527071
resolved "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d"
@@ -8315,6 +8334,13 @@ p-limit@^2.0.0:
83158334
dependencies:
83168335
p-try "^2.0.0"
83178336

8337+
p-limit@^2.2.0:
8338+
version "2.2.0"
8339+
resolved "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz#417c9941e6027a9abcba5092dd2904e255b5fbc2"
8340+
integrity sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==
8341+
dependencies:
8342+
p-try "^2.0.0"
8343+
83188344
p-locate@^2.0.0:
83198345
version "2.0.0"
83208346
resolved "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43"
@@ -8329,6 +8355,13 @@ p-locate@^3.0.0:
83298355
dependencies:
83308356
p-limit "^2.0.0"
83318357

8358+
p-locate@^4.1.0:
8359+
version "4.1.0"
8360+
resolved "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07"
8361+
integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==
8362+
dependencies:
8363+
p-limit "^2.2.0"
8364+
83328365
p-map-series@^1.0.0:
83338366
version "1.0.0"
83348367
resolved "https://registry.npmjs.org/p-map-series/-/p-map-series-1.0.0.tgz#bf98fe575705658a9e1351befb85ae4c1f07bdca"
@@ -10705,6 +10738,11 @@ [email protected]:
1070510738
resolved "https://registry.npmjs.org/typescript/-/typescript-3.5.1.tgz#ba72a6a600b2158139c5dd8850f700e231464202"
1070610739
integrity sha512-64HkdiRv1yYZsSe4xC1WVgamNigVYjlssIoaH2HcZF0+ijsk5YK2g0G34w9wJkze8+5ow4STd22AynfO6ZYYLw==
1070710740

10741+
typescript@^3.5.1:
10742+
version "3.5.2"
10743+
resolved "https://registry.npmjs.org/typescript/-/typescript-3.5.2.tgz#a09e1dc69bc9551cadf17dba10ee42cf55e5d56c"
10744+
integrity sha512-7KxJovlYhTX5RaRbUdkAXN1KUZ8PwWlTzQdHV6xNqvuFOs7+WBo10TQUqT19Q/Jz2hk5v9TQDIhyLhhJY4p5AA==
10745+
1070810746
uglify-js@^3.1.4:
1070910747
version "3.4.9"
1071010748
resolved "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.9.tgz#af02f180c1207d76432e473ed24a28f4a782bae3"

0 commit comments

Comments
 (0)