Skip to content

Commit 6a6a8b0

Browse files
byCedricmarionebl
authored andcommitted
refactor: rewrite top level to typescript (#679)
1 parent 0fedbc0 commit 6a6a8b0

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
@@ -1295,6 +1295,11 @@
12951295
resolved "https://registry.npmjs.org/@types/node/-/node-12.0.2.tgz#3452a24edf9fea138b48fad4a0a028a683da1e40"
12961296
integrity sha512-5tabW/i+9mhrfEOUcLDu2xBPsHJ+X5Orqy9FKpale3SjDA17j5AEpYq5vfy3oAeAHGcvANRCO3NV3d2D6q3NiA==
12971297

1298+
"@types/node@^12.0.4":
1299+
version "12.0.8"
1300+
resolved "https://registry.npmjs.org/@types/node/-/node-12.0.8.tgz#551466be11b2adc3f3d47156758f610bd9f6b1d8"
1301+
integrity sha512-b8bbUOTwzIY3V5vDTY1fIJ+ePKDUBqt2hC2woVGotdQQhG/2Sh62HOKHrT7ab+VerXAcPyAiTEipPu/FsreUtg==
1302+
12981303
"@types/normalize-package-data@^2.4.0":
12991304
version "2.4.0"
13001305
resolved "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e"
@@ -4791,6 +4796,13 @@ find-up@^3.0.0:
47914796
dependencies:
47924797
locate-path "^3.0.0"
47934798

4799+
find-up@^4.0.0:
4800+
version "4.0.0"
4801+
resolved "https://registry.npmjs.org/find-up/-/find-up-4.0.0.tgz#c367f8024de92efb75f2d4906536d24682065c3a"
4802+
integrity sha512-zoH7ZWPkRdgwYCDVoQTzqjG8JSPANhtvLhh4KVUHyKnaUJJrNeFmWIkTcNuJmR3GLMEmGYEf2S2bjgx26JTF+Q==
4803+
dependencies:
4804+
locate-path "^5.0.0"
4805+
47944806
findup-sync@^3.0.0:
47954807
version "3.0.0"
47964808
resolved "https://registry.npmjs.org/findup-sync/-/findup-sync-3.0.0.tgz#17b108f9ee512dfb7a5c7f3c8b27ea9e1a9c08d1"
@@ -7108,6 +7120,13 @@ locate-path@^3.0.0:
71087120
p-locate "^3.0.0"
71097121
path-exists "^3.0.0"
71107122

7123+
locate-path@^5.0.0:
7124+
version "5.0.0"
7125+
resolved "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0"
7126+
integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==
7127+
dependencies:
7128+
p-locate "^4.1.0"
7129+
71117130
lodash._reinterpolate@~3.0.0:
71127131
version "3.0.0"
71137132
resolved "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d"
@@ -8384,6 +8403,13 @@ p-limit@^2.0.0:
83848403
dependencies:
83858404
p-try "^2.0.0"
83868405

8406+
p-limit@^2.2.0:
8407+
version "2.2.0"
8408+
resolved "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz#417c9941e6027a9abcba5092dd2904e255b5fbc2"
8409+
integrity sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==
8410+
dependencies:
8411+
p-try "^2.0.0"
8412+
83878413
p-locate@^2.0.0:
83888414
version "2.0.0"
83898415
resolved "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43"
@@ -8398,6 +8424,13 @@ p-locate@^3.0.0:
83988424
dependencies:
83998425
p-limit "^2.0.0"
84008426

8427+
p-locate@^4.1.0:
8428+
version "4.1.0"
8429+
resolved "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07"
8430+
integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==
8431+
dependencies:
8432+
p-limit "^2.2.0"
8433+
84018434
p-map-series@^1.0.0:
84028435
version "1.0.0"
84038436
resolved "https://registry.npmjs.org/p-map-series/-/p-map-series-1.0.0.tgz#bf98fe575705658a9e1351befb85ae4c1f07bdca"
@@ -10796,6 +10829,11 @@ [email protected]:
1079610829
resolved "https://registry.npmjs.org/typescript/-/typescript-3.5.2.tgz#a09e1dc69bc9551cadf17dba10ee42cf55e5d56c"
1079710830
integrity sha512-7KxJovlYhTX5RaRbUdkAXN1KUZ8PwWlTzQdHV6xNqvuFOs7+WBo10TQUqT19Q/Jz2hk5v9TQDIhyLhhJY4p5AA==
1079810831

10832+
typescript@^3.5.1:
10833+
version "3.5.2"
10834+
resolved "https://registry.npmjs.org/typescript/-/typescript-3.5.2.tgz#a09e1dc69bc9551cadf17dba10ee42cf55e5d56c"
10835+
integrity sha512-7KxJovlYhTX5RaRbUdkAXN1KUZ8PwWlTzQdHV6xNqvuFOs7+WBo10TQUqT19Q/Jz2hk5v9TQDIhyLhhJY4p5AA==
10836+
1079910837
uglify-js@^3.1.4:
1080010838
version "3.4.9"
1080110839
resolved "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.9.tgz#af02f180c1207d76432e473ed24a28f4a782bae3"

0 commit comments

Comments
 (0)