Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
2 changes: 0 additions & 2 deletions @commitlint/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
},
"scripts": {
"build": "cross-env NODE_ENV=production babel src --out-dir lib --source-maps",
"clean": "npx rimraf lib",
"deps": "dep-check",
"pkg": "pkg-check",
"start": "concurrently \"ava -c 4 --verbose --watch\" \"yarn run watch\"",
Expand Down Expand Up @@ -66,7 +65,6 @@
"mkdirp": "0.5.1",
"pkg-dir": "2.0.0",
"resolve-bin": "0.4.0",
"rimraf": "2.6.2",
"sander": "0.6.0",
"string-to-stream": "1.1.0",
"tmp": "0.1.0"
Expand Down
4 changes: 1 addition & 3 deletions @commitlint/ensure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
],
"scripts": {
"build": "cross-env NODE_ENV=production babel src --out-dir lib --source-maps",
"clean": "npx rimraf lib",
"deps": "dep-check",
"pkg": "pkg-check --skip-import",
"start": "concurrently \"ava -c 4 --verbose --watch\" \"yarn run watch\"",
Expand Down Expand Up @@ -65,8 +64,7 @@
"babel-register": "6.26.0",
"concurrently": "3.5.1",
"cross-env": "5.1.1",
"globby": "8.0.1",
"rimraf": "2.6.1"
"globby": "8.0.1"
},
"dependencies": {
"lodash": "4.17.11"
Expand Down
1 change: 1 addition & 0 deletions @commitlint/execute-rule/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/execute-rule/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./lib');
4 changes: 4 additions & 0 deletions @commitlint/execute-rule/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node'
};
45 changes: 10 additions & 35 deletions @commitlint/execute-rule/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,12 @@
"lib/"
],
"scripts": {
"build": "cross-env NODE_ENV=production babel src --out-dir lib --source-maps",
"clean": "npx rimraf lib",
"build": "tsc",
"deps": "dep-check",
"pkg": "pkg-check",
"start": "concurrently \"ava -c 4 --verbose --watch\" \"yarn run watch\"",
"test": "ava -c 4 --verbose",
"watch": "babel src --out-dir lib --watch --source-maps"
},
"ava": {
"files": [
"src/**/*.test.js",
"!lib/**/*"
],
"source": [
"src/**/*.js",
"!lib/**/*"
],
"babel": "inherit",
"require": [
"babel-register"
]
},
"babel": {
"presets": [
"babel-preset-commitlint"
]
"start": "concurrently \"yarn test --watchAll\" \"yarn run watch\"",
"test": "jest",
"watch": "tsc -w"
},
"engines": {
"node": ">=4"
Expand All @@ -58,17 +38,12 @@
"license": "MIT",
"devDependencies": {
"@commitlint/parse": "^7.5.0",
"@commitlint/test": "7.6.0",
"@commitlint/utils": "^7.5.0",
"ava": "0.22.0",
"babel-cli": "6.26.0",
"babel-preset-commitlint": "^7.5.0",
"babel-register": "6.26.0",
"@types/jest": "24.0.13",
"@types/lodash": "4.14.130",
"concurrently": "3.5.1",
"cross-env": "5.1.1",
"rimraf": "2.6.1"
},
"dependencies": {
"babel-runtime": "6.26.0"
"jest": "24.8.0",
"ts-jest": "24.0.2",
"typescript": "3.4.5"
}
}
}
9 changes: 0 additions & 9 deletions @commitlint/execute-rule/src/index.js

This file was deleted.

27 changes: 0 additions & 27 deletions @commitlint/execute-rule/src/index.test.js

This file was deleted.

26 changes: 26 additions & 0 deletions @commitlint/execute-rule/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import execute from '.';

test('does nothing without params', async () => {
const exec = execute as any;
expect(await exec()).toBeNull();
});

test('returns plain config', async () => {
const actual = await execute(['name', 'config']);
expect(actual).toEqual(['name', 'config']);
});

test('unwraps promised config', async () => {
const actual = await execute(['name', Promise.resolve('config')]);
expect(actual).toEqual(['name', 'config']);
});

test('executes config functions', async () => {
const actual = await execute(['name', () => 'config']);
expect(actual).toEqual(['name', 'config']);
});

test('executes async config functions', async () => {
const actual = await execute(['name', async () => 'config']);
expect(actual).toEqual(['name', 'config']);
});
25 changes: 25 additions & 0 deletions @commitlint/execute-rule/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
type Rule<T> = readonly [string, Config<T>];
type Config<T> = T | Promise<T> | ExectableConfig<T>;
type ExectableConfig<T> = (() => T) | (() => Promise<T>);

type ExecutedRule<T> = readonly [string, T];

export default execute;

export async function execute<T = unknown>(rule: Rule<T>): Promise<ExecutedRule<T> | null> {
if (!Array.isArray(rule)) {
return null;
}

const [name, config] = rule;

const fn = executable(config)
? config
: async () => config;

return [name, await fn()];
};

function executable<T>(config: Config<T>): config is ExectableConfig<T> {
return typeof config === 'function';
}
22 changes: 22 additions & 0 deletions @commitlint/execute-rule/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"
]
}
6 changes: 2 additions & 4 deletions @commitlint/format/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
],
"scripts": {
"build": "tsc",
"clean": "npx rimraf lib",
"deps": "dep-check",
"pkg": "pkg-check --skip-import",
"start": "concurrently \"yarn test --watchAll\" \"yarn run watch\"",
Expand Down Expand Up @@ -38,16 +37,15 @@
},
"license": "MIT",
"devDependencies": {
"@commitlint/test": "7.6.0",
"@commitlint/utils": "^7.5.0",
"@types/jest": "24.0.13",
"@types/lodash": "4.14.130",
"concurrently": "3.5.1",
"cross-env": "5.1.1",
"jest": "24.8.0",
"rimraf": "2.6.1",
"ts-jest": "24.0.2",
"typescript": "3.4.5"
"typescript": "3.4.5",
"lodash": "4.17.11"
},
"dependencies": {
"chalk": "^2.0.1"
Expand Down
4 changes: 1 addition & 3 deletions @commitlint/is-ignored/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
],
"scripts": {
"build": "cross-env NODE_ENV=production babel src --out-dir lib --source-maps",
"clean": "npx rimraf lib",
"deps": "dep-check",
"pkg": "pkg-check",
"start": "concurrently \"ava -c 4 --verbose --watch\" \"yarn run watch\"",
Expand Down Expand Up @@ -65,8 +64,7 @@
"babel-preset-commitlint": "^7.5.0",
"babel-register": "6.26.0",
"concurrently": "3.5.1",
"cross-env": "5.1.1",
"rimraf": "2.6.1"
"cross-env": "5.1.1"
},
"dependencies": {
"semver": "6.0.0"
Expand Down
2 changes: 0 additions & 2 deletions @commitlint/lint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
],
"scripts": {
"build": "cross-env NODE_ENV=production babel src --out-dir lib --source-maps",
"clean": "npx rimraf lib",
"deps": "dep-check",
"pkg": "pkg-check --skip-import",
"start": "concurrently \"ava -c 4 --verbose --watch\" \"yarn run watch\"",
Expand Down Expand Up @@ -67,7 +66,6 @@
"cross-env": "5.1.1",
"execa": "0.9.0",
"globby": "8.0.1",
"rimraf": "2.6.1",
"proxyquire": "2.1.0"
},
"dependencies": {
Expand Down
4 changes: 1 addition & 3 deletions @commitlint/load/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
],
"scripts": {
"build": "cross-env NODE_ENV=production babel src --out-dir lib --source-maps",
"clean": "npx rimraf lib",
"deps": "dep-check",
"pkg": "pkg-check --skip-import",
"start": "concurrently \"ava -c 4 --verbose --watch\" \"yarn run watch\"",
Expand Down Expand Up @@ -66,8 +65,7 @@
"concurrently": "3.5.1",
"cross-env": "5.1.1",
"execa": "0.9.0",
"globby": "8.0.1",
"rimraf": "2.6.1"
"globby": "8.0.1"
},
"dependencies": {
"@commitlint/execute-rule": "^7.5.0",
Expand Down
4 changes: 1 addition & 3 deletions @commitlint/message/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
],
"scripts": {
"build": "cross-env NODE_ENV=production babel src --out-dir lib --source-maps",
"clean": "npx rimraf lib",
"deps": "dep-check",
"pkg": "pkg-check",
"start": "concurrently \"ava -c 4 --verbose --watch\" \"yarn run watch\"",
Expand Down Expand Up @@ -64,7 +63,6 @@
"babel-preset-commitlint": "^7.5.0",
"babel-register": "6.26.0",
"concurrently": "3.5.1",
"cross-env": "5.1.1",
"rimraf": "2.6.1"
"cross-env": "5.1.1"
}
}
4 changes: 1 addition & 3 deletions @commitlint/parse/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
],
"scripts": {
"build": "cross-env NODE_ENV=production babel src --out-dir lib --source-maps",
"clean": "npx rimraf lib",
"deps": "dep-check",
"pkg": "pkg-check",
"start": "concurrently \"ava -c 4 --verbose --watch\" \"yarn run watch\"",
Expand Down Expand Up @@ -65,8 +64,7 @@
"babel-register": "6.26.0",
"concurrently": "3.5.1",
"cross-env": "5.1.1",
"import-from": "3.0.0",
"rimraf": "2.6.1"
"import-from": "3.0.0"
},
"dependencies": {
"conventional-changelog-angular": "^1.3.3",
Expand Down
1 change: 0 additions & 1 deletion @commitlint/prompt-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"commit": "./cli.js"
},
"scripts": {
"clean": "npx rimraf lib",
"commit": "$npm_package_bin_commit",
"deps": "dep-check",
"pkg": "pkg-check --skip-main",
Expand Down
1 change: 0 additions & 1 deletion @commitlint/prompt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
],
"scripts": {
"build": "cross-env NODE_ENV=production babel src --out-dir lib --source-maps",
"clean": "npx rimraf lib",
"commit": "git-cz",
"deps": "dep-check",
"pkg": "pkg-check --skip-import",
Expand Down
4 changes: 1 addition & 3 deletions @commitlint/read/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
],
"scripts": {
"build": "cross-env NODE_ENV=production babel src --out-dir lib --source-maps",
"clean": "npx rimraf lib",
"deps": "dep-check",
"pkg": "pkg-check --skip-import",
"start": "concurrently \"ava -c 4 --verbose --watch\" \"yarn run watch\"",
Expand Down Expand Up @@ -65,8 +64,7 @@
"babel-register": "6.26.0",
"concurrently": "3.5.1",
"cross-env": "5.1.1",
"execa": "0.9.0",
"rimraf": "2.6.1"
"execa": "0.9.0"
},
"dependencies": {
"@commitlint/top-level": "^7.5.0",
Expand Down
4 changes: 1 addition & 3 deletions @commitlint/resolve-extends/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
],
"scripts": {
"build": "cross-env NODE_ENV=production babel src --out-dir lib --source-maps",
"clean": "npx rimraf lib",
"deps": "dep-check",
"pkg": "pkg-check",
"start": "concurrently \"ava -c 4 --verbose --watch\" \"yarn run watch\"",
Expand Down Expand Up @@ -67,8 +66,7 @@
"babel-register": "6.26.0",
"concurrently": "3.5.1",
"cross-env": "5.1.1",
"execa": "0.9.0",
"rimraf": "2.6.1"
"execa": "0.9.0"
},
"dependencies": {
"babel-runtime": "6.26.0",
Expand Down
Loading