Skip to content

Commit

Permalink
refactor: rewrite top level to typescript (#679)
Browse files Browse the repository at this point in the history
  • Loading branch information
byCedric authored and marionebl committed Jul 7, 2019
1 parent 0fedbc0 commit 6a6a8b0
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 8 deletions.
1 change: 1 addition & 0 deletions @commitlint/top-level/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib';
1 change: 1 addition & 0 deletions @commitlint/top-level/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./lib');
10 changes: 6 additions & 4 deletions @commitlint/top-level/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import up from 'find-up';

export default toplevel;

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

This comment has been minimized.

Copy link
@huanghai21

huanghai21 Sep 9, 2019

Contributor

Hi @byCedric & @marionebl
About the refactor here, you add one condition that the type to be 'directory'. But you know that with the git submodule, the .git is a file, not a directory. Can u help to fix this and do a republish on the NPM.

Thank you.


if (typeof found !== 'string') {
return found;
Expand Down
22 changes: 22 additions & 0 deletions @commitlint/top-level/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
38 changes: 38 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,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"
Expand Down Expand Up @@ -4791,6 +4796,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"
Expand Down Expand Up @@ -7108,6 +7120,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"
Expand Down Expand Up @@ -8384,6 +8403,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"
Expand All @@ -8398,6 +8424,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"
Expand Down Expand Up @@ -10796,6 +10829,11 @@ typescript@3.5.2:
resolved "https://registry.npmjs.org/typescript/-/typescript-3.5.2.tgz#a09e1dc69bc9551cadf17dba10ee42cf55e5d56c"
integrity sha512-7KxJovlYhTX5RaRbUdkAXN1KUZ8PwWlTzQdHV6xNqvuFOs7+WBo10TQUqT19Q/Jz2hk5v9TQDIhyLhhJY4p5AA==

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"
Expand Down

0 comments on commit 6a6a8b0

Please sign in to comment.