Skip to content

Commit 810d9b5

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

File tree

6 files changed

+81
-1381
lines changed

6 files changed

+81
-1381
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.ts

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import path from 'path';
2+
import up from 'find-up';
3+
4+
export default toplevel;
5+
6+
/**
7+
* Find the next git root
8+
*/
9+
async function toplevel(cwd: string) {
10+
const found = await up('.git', { cwd, type: 'directory' });
11+
12+
if (typeof found !== 'string') {
13+
return found;
14+
}
15+
16+
return path.join(found, '..');
17+
}

@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+
}

0 commit comments

Comments
 (0)