@commitlint/load
Advanced tools
Comparing version
174
lib/index.js
@@ -49,34 +49,49 @@ 'use strict'; | ||
var w = function w(a, b) { | ||
return Array.isArray(b) ? b : undefined; | ||
}; | ||
var valid = function valid(input) { | ||
return (0, _lodash8.default)(input, 'extends', 'rules', 'parserPreset'); | ||
}; | ||
const w = (a, b) => Array.isArray(b) ? b : undefined; | ||
const valid = input => (0, _lodash8.default)(input, 'extends', 'rules', 'parserPreset'); | ||
exports.default = function () { | ||
var $args = arguments;return new Promise(function ($return, $error) { | ||
var seed, options, loaded, base, config, opts, resolvedParserPreset, extended, preset, executed; | ||
seed = $args.length > 0 && $args[0] !== undefined ? $args[0] : {}; | ||
options = $args.length > 1 && $args[1] !== undefined ? $args[1] : { cwd: process.cwd() }; | ||
return Promise.resolve(loadConfig(options.cwd, options.file)).then(function ($await_3) { | ||
try { | ||
loaded = $await_3; | ||
base = loaded.filepath ? _path2.default.dirname(loaded.filepath) : options.cwd; | ||
exports.default = (seed = {}, options = { cwd: process.cwd() }) => new Promise(function ($return, $error) { | ||
var loaded, base, config, opts, resolvedParserPreset, extended, preset, executed; | ||
return Promise.resolve(loadConfig(options.cwd, options.file)).then(function ($await_3) { | ||
try { | ||
loaded = $await_3; | ||
base = loaded.filepath ? _path2.default.dirname(loaded.filepath) : options.cwd; | ||
config = valid((0, _lodash4.default)(loaded.config, seed)); | ||
opts = (0, _lodash4.default)({ extends: [], rules: {} }, (0, _lodash8.default)(config, 'extends')); | ||
config = valid((0, _lodash4.default)(loaded.config, seed)); | ||
opts = (0, _lodash4.default)({ extends: [], rules: {} }, (0, _lodash8.default)(config, 'extends')); | ||
// Resolve parserPreset key | ||
if (typeof config.parserPreset === 'string') { | ||
resolvedParserPreset = (0, _resolveFrom2.default)(base, config.parserPreset); | ||
// Resolve parserPreset key | ||
if (typeof config.parserPreset === 'string') { | ||
resolvedParserPreset = (0, _resolveFrom2.default)(base, config.parserPreset); | ||
return Promise.resolve(require(resolvedParserPreset)).then(function ($await_4) { | ||
try { | ||
return Promise.resolve(require(resolvedParserPreset)).then(function ($await_4) { | ||
config.parserPreset = { | ||
name: config.parserPreset, | ||
path: resolvedParserPreset, | ||
parserOpts: $await_4.parserOpts | ||
}; | ||
return $If_1.call(this); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} | ||
// Resolve extends key | ||
function $If_1() { | ||
extended = (0, _resolveExtends2.default)(opts, { | ||
prefix: 'commitlint-config', | ||
cwd: base, | ||
parserPreset: config.parserPreset | ||
}); | ||
preset = valid((0, _lodash6.default)(extended, config, w)); | ||
// Await parser-preset if applicable | ||
if (typeof preset.parserPreset === 'object' && typeof preset.parserPreset.parserOpts === 'object' && typeof preset.parserPreset.parserOpts.then === 'function') { | ||
return Promise.resolve(preset.parserPreset.parserOpts).then(function ($await_5) { | ||
try { | ||
config.parserPreset = { | ||
name: config.parserPreset, | ||
path: resolvedParserPreset, | ||
parserOpts: $await_4.parserOpts | ||
}; | ||
return $If_1.call(this); | ||
preset.parserPreset.parserOpts = $await_5.parserOpts; | ||
return $If_2.call(this); | ||
} catch ($boundEx) { | ||
@@ -88,65 +103,23 @@ return $error($boundEx); | ||
// Resolve extends key | ||
// Execute rule config functions if needed | ||
function $If_1() { | ||
extended = (0, _resolveExtends2.default)(opts, { | ||
prefix: 'commitlint-config', | ||
cwd: base, | ||
parserPreset: config.parserPreset | ||
}); | ||
function $If_2() { | ||
return Promise.resolve(Promise.all(['rules'].map(key => [key, preset[key]]).map(item => new Promise(function ($return, $error) { | ||
var _item, key, value, executedValue; | ||
preset = valid((0, _lodash6.default)(extended, config, w)); | ||
// Await parser-preset if applicable | ||
if (typeof preset.parserPreset === 'object' && typeof preset.parserPreset.parserOpts === 'object' && typeof preset.parserPreset.parserOpts.then === 'function') { | ||
return Promise.resolve(preset.parserPreset.parserOpts).then(function ($await_5) { | ||
_item = (0, _slicedToArray3.default)(item, 2); | ||
key = _item[0], value = _item[1]; | ||
return Promise.resolve(Promise.all((0, _lodash2.default)(value || {}).map(entry => (0, _executeRule2.default)(entry)))).then(function ($await_6) { | ||
try { | ||
preset.parserPreset.parserOpts = $await_5.parserOpts; | ||
return $If_2.call(this); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} | ||
executedValue = $await_6; | ||
// Execute rule config functions if needed | ||
return $return([key, executedValue.reduce((registry, item) => { | ||
var _item2 = (0, _slicedToArray3.default)(item, 2); | ||
function $If_2() { | ||
return Promise.resolve(Promise.all(['rules'].map(function (key) { | ||
return [key, preset[key]]; | ||
}).map(function (item) { | ||
return new Promise(function ($return, $error) { | ||
var _item, key, value, executedValue; | ||
const key = _item2[0], | ||
value = _item2[1]; | ||
_item = (0, _slicedToArray3.default)(item, 2), key = _item[0], value = _item[1]; | ||
return Promise.resolve(Promise.all((0, _lodash2.default)(value || {}).map(function (entry) { | ||
return (0, _executeRule2.default)(entry); | ||
}))).then(function ($await_6) { | ||
try { | ||
executedValue = $await_6; | ||
return $return([key, executedValue.reduce(function (registry, item) { | ||
var _item2 = (0, _slicedToArray3.default)(item, 2), | ||
key = _item2[0], | ||
value = _item2[1]; | ||
registry[key] = value; | ||
return registry; | ||
}, {})]); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this)); | ||
}))).then(function ($await_7) { | ||
try { | ||
executed = $await_7; | ||
// Merge executed config keys into preset | ||
return $return(executed.reduce(function (registry, item) { | ||
var _item3 = (0, _slicedToArray3.default)(item, 2), | ||
key = _item3[0], | ||
value = _item3[1]; | ||
registry[key] = value; | ||
return registry; | ||
}, preset)); | ||
}, {})]); | ||
} catch ($boundEx) { | ||
@@ -156,19 +129,36 @@ return $error($boundEx); | ||
}.bind(this), $error); | ||
} | ||
}.bind(this))))).then(function ($await_7) { | ||
try { | ||
executed = $await_7; | ||
return $If_2.call(this); | ||
// Merge executed config keys into preset | ||
return $return(executed.reduce((registry, item) => { | ||
var _item3 = (0, _slicedToArray3.default)(item, 2); | ||
const key = _item3[0], | ||
value = _item3[1]; | ||
registry[key] = value; | ||
return registry; | ||
}, preset)); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} | ||
return $If_1.call(this); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
return $If_2.call(this); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this)); | ||
}; | ||
return $If_1.call(this); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this)); | ||
function loadConfig(cwd, configPath) { | ||
return new Promise(function ($return, $error) { | ||
var explorer, local; | ||
explorer = (0, _cosmiconfig2.default)('commitlint', { | ||
@@ -178,3 +168,2 @@ rcExtensions: true, | ||
}); | ||
return Promise.resolve(explorer.load(cwd)).then(function ($await_8) { | ||
@@ -184,2 +173,3 @@ try { | ||
if (local) { | ||
@@ -186,0 +176,0 @@ return $return(local); |
@@ -15,53 +15,53 @@ 'use strict'; | ||
_ava2.default.serial('default cwd option to process.cwd()', function (t) { | ||
return new Promise(function ($return, $error) { | ||
var $Try_1_Finally = function ($Try_1_Exit) { | ||
return function ($Try_1_Value) { | ||
_ava2.default.serial('default cwd option to process.cwd()', t => new Promise(function ($return, $error) { | ||
var $Try_1_Finally = function ($Try_1_Exit) { | ||
return function ($Try_1_Value) { | ||
try { | ||
process.chdir(before); | ||
return $Try_1_Exit && $Try_1_Exit.call(this, $Try_1_Value); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this); | ||
}.bind(this); | ||
var cwd, before, actual; | ||
return Promise.resolve(_test.fix.bootstrap('fixtures/basic')).then(function ($await_2) { | ||
try { | ||
cwd = $await_2; | ||
before = process.cwd(); | ||
process.chdir(cwd); | ||
var $Try_1_Post = function () { | ||
try { | ||
process.chdir(before); | ||
return $Try_1_Exit && $Try_1_Exit.call(this, $Try_1_Value); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this); | ||
}.bind(this); | ||
}.bind(this);var $Try_1_Catch = function (err) { | ||
try { | ||
throw err; | ||
} catch ($boundEx) { | ||
return $Try_1_Finally($error)($boundEx); | ||
} | ||
}.bind(this);try { | ||
return Promise.resolve((0, _2.default)()).then(function ($await_3) { | ||
try { | ||
actual = $await_3; | ||
var cwd, before, actual; | ||
return Promise.resolve(_test.fix.bootstrap('fixtures/basic')).then(function ($await_2) { | ||
try { | ||
cwd = $await_2; | ||
before = process.cwd(); | ||
process.chdir(cwd); | ||
var $Try_1_Post = function () { | ||
try { | ||
return $return(); | ||
t.true(actual.rules.basic); | ||
return $Try_1_Finally($Try_1_Post)(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
return $Try_1_Catch($boundEx); | ||
} | ||
}.bind(this);var $Try_1_Catch = function (err) { | ||
try { | ||
throw err; | ||
} catch ($boundEx) { | ||
return $Try_1_Finally($error)($boundEx); | ||
} | ||
}.bind(this);try { | ||
return Promise.resolve((0, _2.default)()).then(function ($await_3) { | ||
try { | ||
actual = $await_3; | ||
t.true(actual.rules.basic); | ||
return $Try_1_Finally($Try_1_Post)(); | ||
} catch ($boundEx) { | ||
return $Try_1_Catch($boundEx); | ||
} | ||
}.bind(this), $Try_1_Catch); | ||
} catch (err) { | ||
$Try_1_Catch(err) | ||
} | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
}.bind(this), $Try_1_Catch); | ||
} catch (err) { | ||
$Try_1_Catch(err) | ||
} | ||
}.bind(this), $error); | ||
}.bind(this)); | ||
}); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this))); | ||
//# sourceMappingURL=index.serial-test.js.map |
@@ -19,521 +19,499 @@ 'use strict'; | ||
(0, _ava2.default)('extends-empty should have no rules', function (t) { | ||
return new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/extends-empty')).then(function ($await_1) { | ||
try { | ||
cwd = $await_1; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_2) { | ||
try { | ||
actual = $await_2; | ||
t.deepEqual(actual.rules, {}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this)); | ||
}); | ||
(0, _ava2.default)('extends-empty should have no rules', t => new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/extends-empty')).then(function ($await_1) { | ||
try { | ||
cwd = $await_1; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_2) { | ||
try { | ||
actual = $await_2; | ||
(0, _ava2.default)('uses seed as configured', function (t) { | ||
return new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/extends-empty')).then(function ($await_3) { | ||
try { | ||
cwd = $await_3; | ||
return Promise.resolve((0, _2.default)({ rules: { foo: 'bar' } }, { cwd })).then(function ($await_4) { | ||
try { | ||
actual = $await_4; | ||
t.is(actual.rules.foo, 'bar'); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this)); | ||
}); | ||
t.deepEqual(actual.rules, {}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this))); | ||
(0, _ava2.default)('rules should be loaded from specify config file', function (t) { | ||
return new Promise(function ($return, $error) { | ||
var file, cwd, actual; | ||
(0, _ava2.default)('uses seed as configured', t => new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/extends-empty')).then(function ($await_3) { | ||
try { | ||
cwd = $await_3; | ||
return Promise.resolve((0, _2.default)({ rules: { foo: 'bar' } }, { cwd })).then(function ($await_4) { | ||
try { | ||
actual = $await_4; | ||
file = 'config/commitlint.config.js'; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/specify-config-file')).then(function ($await_5) { | ||
try { | ||
cwd = $await_5; | ||
return Promise.resolve((0, _2.default)({}, { cwd, file })).then(function ($await_6) { | ||
try { | ||
actual = $await_6; | ||
t.is(actual.rules.foo, 'bar'); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this)); | ||
}); | ||
t.is(actual.rules.foo, 'bar'); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this))); | ||
(0, _ava2.default)('uses seed with parserPreset', function (t) { | ||
return new Promise(function ($return, $error) { | ||
var cwd, _ref, actual; | ||
(0, _ava2.default)('rules should be loaded from specify config file', t => new Promise(function ($return, $error) { | ||
var file, cwd, actual; | ||
file = 'config/commitlint.config.js'; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/specify-config-file')).then(function ($await_5) { | ||
try { | ||
cwd = $await_5; | ||
return Promise.resolve((0, _2.default)({}, { cwd, file })).then(function ($await_6) { | ||
try { | ||
actual = $await_6; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/parser-preset')).then(function ($await_7) { | ||
try { | ||
cwd = $await_7; | ||
return Promise.resolve((0, _2.default)({ | ||
parserPreset: './conventional-changelog-custom' | ||
}, { cwd })).then(function ($await_8) { | ||
try { | ||
_ref = $await_8, actual = _ref.parserPreset; | ||
t.is(actual.rules.foo, 'bar'); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this))); | ||
t.is(actual.name, './conventional-changelog-custom'); | ||
t.deepEqual(actual.parserOpts, { | ||
headerPattern: /^(\w*)(?:\((.*)\))?-(.*)$/ | ||
}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this)); | ||
}); | ||
(0, _ava2.default)('uses seed with parserPreset', t => new Promise(function ($return, $error) { | ||
var cwd, _ref, actual; | ||
(0, _ava2.default)('invalid extend should throw', function (t) { | ||
return new Promise(function ($return, $error) { | ||
var cwd; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/extends-invalid')).then(function ($await_9) { | ||
try { | ||
cwd = $await_9; | ||
return Promise.resolve(t.throws((0, _2.default)({}, { cwd }))).then(function ($await_10) { | ||
try { | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this)); | ||
}); | ||
return Promise.resolve(_test.git.bootstrap('fixtures/parser-preset')).then(function ($await_7) { | ||
try { | ||
cwd = $await_7; | ||
return Promise.resolve((0, _2.default)({ | ||
parserPreset: './conventional-changelog-custom' | ||
}, { cwd })).then(function ($await_8) { | ||
try { | ||
_ref = $await_8; | ||
actual = _ref.parserPreset; | ||
(0, _ava2.default)('empty file should have no rules', function (t) { | ||
return new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/empty-object-file')).then(function ($await_11) { | ||
try { | ||
cwd = $await_11; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_12) { | ||
try { | ||
actual = $await_12; | ||
t.deepEqual(actual.rules, {}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this)); | ||
}); | ||
t.is(actual.name, './conventional-changelog-custom'); | ||
t.deepEqual(actual.parserOpts, { | ||
headerPattern: /^(\w*)(?:\((.*)\))?-(.*)$/ | ||
}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this))); | ||
(0, _ava2.default)('empty file should extend nothing', function (t) { | ||
return new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/empty-file')).then(function ($await_13) { | ||
try { | ||
cwd = $await_13; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_14) { | ||
try { | ||
actual = $await_14; | ||
t.deepEqual(actual.extends, []); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this)); | ||
}); | ||
(0, _ava2.default)('invalid extend should throw', t => new Promise(function ($return, $error) { | ||
var cwd; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/extends-invalid')).then(function ($await_9) { | ||
try { | ||
cwd = $await_9; | ||
return Promise.resolve(t.throws((0, _2.default)({}, { cwd }))).then(function ($await_10) { | ||
try { | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this))); | ||
(0, _ava2.default)('respects cwd option', function (t) { | ||
return new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/recursive-extends/first-extended')).then(function ($await_15) { | ||
try { | ||
cwd = $await_15; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_16) { | ||
try { | ||
actual = $await_16; | ||
t.deepEqual(actual, { | ||
extends: ['./second-extended'], | ||
rules: { | ||
one: 1, | ||
two: 2 | ||
} | ||
}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this)); | ||
}); | ||
(0, _ava2.default)('empty file should have no rules', t => new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/empty-object-file')).then(function ($await_11) { | ||
try { | ||
cwd = $await_11; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_12) { | ||
try { | ||
actual = $await_12; | ||
(0, _ava2.default)('recursive extends', function (t) { | ||
return new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/recursive-extends')).then(function ($await_17) { | ||
try { | ||
cwd = $await_17; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_18) { | ||
try { | ||
actual = $await_18; | ||
t.deepEqual(actual, { | ||
extends: ['./first-extended'], | ||
rules: { | ||
zero: 0, | ||
one: 1, | ||
two: 2 | ||
} | ||
}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this)); | ||
}); | ||
t.deepEqual(actual.rules, {}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this))); | ||
(0, _ava2.default)('recursive extends with json file', function (t) { | ||
return new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/recursive-extends-json')).then(function ($await_19) { | ||
try { | ||
cwd = $await_19; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_20) { | ||
try { | ||
actual = $await_20; | ||
(0, _ava2.default)('empty file should extend nothing', t => new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/empty-file')).then(function ($await_13) { | ||
try { | ||
cwd = $await_13; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_14) { | ||
try { | ||
actual = $await_14; | ||
t.deepEqual(actual, { | ||
extends: ['./first-extended'], | ||
rules: { | ||
zero: 0, | ||
one: 1, | ||
two: 2 | ||
} | ||
}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this)); | ||
}); | ||
t.deepEqual(actual.extends, []); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this))); | ||
(0, _ava2.default)('recursive extends with yaml file', function (t) { | ||
return new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/recursive-extends-yaml')).then(function ($await_21) { | ||
try { | ||
cwd = $await_21; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_22) { | ||
try { | ||
actual = $await_22; | ||
(0, _ava2.default)('respects cwd option', t => new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/recursive-extends/first-extended')).then(function ($await_15) { | ||
try { | ||
cwd = $await_15; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_16) { | ||
try { | ||
actual = $await_16; | ||
t.deepEqual(actual, { | ||
extends: ['./first-extended'], | ||
rules: { | ||
zero: 0, | ||
one: 1, | ||
two: 2 | ||
} | ||
}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this)); | ||
}); | ||
t.deepEqual(actual, { | ||
extends: ['./second-extended'], | ||
rules: { | ||
one: 1, | ||
two: 2 | ||
} | ||
}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this))); | ||
(0, _ava2.default)('recursive extends with js file', function (t) { | ||
return new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/recursive-extends-js')).then(function ($await_23) { | ||
try { | ||
cwd = $await_23; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_24) { | ||
try { | ||
actual = $await_24; | ||
(0, _ava2.default)('recursive extends', t => new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/recursive-extends')).then(function ($await_17) { | ||
try { | ||
cwd = $await_17; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_18) { | ||
try { | ||
actual = $await_18; | ||
t.deepEqual(actual, { | ||
extends: ['./first-extended'], | ||
rules: { | ||
zero: 0, | ||
one: 1, | ||
two: 2 | ||
} | ||
}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this)); | ||
}); | ||
t.deepEqual(actual, { | ||
extends: ['./first-extended'], | ||
rules: { | ||
zero: 0, | ||
one: 1, | ||
two: 2 | ||
} | ||
}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this))); | ||
(0, _ava2.default)('recursive extends with package.json file', function (t) { | ||
return new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/recursive-extends-package')).then(function ($await_25) { | ||
try { | ||
cwd = $await_25; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_26) { | ||
try { | ||
actual = $await_26; | ||
(0, _ava2.default)('recursive extends with json file', t => new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/recursive-extends-json')).then(function ($await_19) { | ||
try { | ||
cwd = $await_19; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_20) { | ||
try { | ||
actual = $await_20; | ||
t.deepEqual(actual, { | ||
extends: ['./first-extended'], | ||
rules: { | ||
zero: 0, | ||
one: 1, | ||
two: 2 | ||
} | ||
}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this)); | ||
}); | ||
(0, _ava2.default)('parser preset overwrites completely instead of merging', function (t) { | ||
return new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/parser-preset-override')).then(function ($await_27) { | ||
try { | ||
cwd = $await_27; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_28) { | ||
try { | ||
actual = $await_28; | ||
t.is(actual.parserPreset.name, './custom'); | ||
t.deepEqual(actual.parserPreset.parserOpts, { | ||
headerPattern: /.*/ | ||
}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this)); | ||
}); | ||
t.deepEqual(actual, { | ||
extends: ['./first-extended'], | ||
rules: { | ||
zero: 0, | ||
one: 1, | ||
two: 2 | ||
} | ||
}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this))); | ||
(0, _ava2.default)('recursive extends with parserPreset', function (t) { | ||
return new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/recursive-parser-preset')).then(function ($await_29) { | ||
try { | ||
cwd = $await_29; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_30) { | ||
try { | ||
actual = $await_30; | ||
t.is(actual.parserPreset.name, './conventional-changelog-custom'); | ||
t.is(typeof actual.parserPreset.parserOpts, 'object'); | ||
t.deepEqual(actual.parserPreset.parserOpts.headerPattern, /^(\w*)(?:\((.*)\))?-(.*)$/); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this)); | ||
}); | ||
(0, _ava2.default)('recursive extends with yaml file', t => new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/recursive-extends-yaml')).then(function ($await_21) { | ||
try { | ||
cwd = $await_21; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_22) { | ||
try { | ||
actual = $await_22; | ||
(0, _ava2.default)('ignores unknow keys', function (t) { | ||
return new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/trash-file')).then(function ($await_31) { | ||
try { | ||
cwd = $await_31; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_32) { | ||
try { | ||
actual = $await_32; | ||
t.deepEqual(actual, { | ||
extends: [], | ||
rules: { | ||
foo: 'bar', | ||
baz: 'bar' | ||
} | ||
}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this)); | ||
}); | ||
t.deepEqual(actual, { | ||
extends: ['./first-extended'], | ||
rules: { | ||
zero: 0, | ||
one: 1, | ||
two: 2 | ||
} | ||
}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this))); | ||
(0, _ava2.default)('ignores unknow keys recursively', function (t) { | ||
return new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/trash-extend')).then(function ($await_33) { | ||
try { | ||
cwd = $await_33; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_34) { | ||
try { | ||
actual = $await_34; | ||
(0, _ava2.default)('recursive extends with js file', t => new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/recursive-extends-js')).then(function ($await_23) { | ||
try { | ||
cwd = $await_23; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_24) { | ||
try { | ||
actual = $await_24; | ||
t.deepEqual(actual, { | ||
extends: ['./one'], | ||
rules: { | ||
zero: 0, | ||
one: 1 | ||
} | ||
}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this)); | ||
}); | ||
(0, _ava2.default)('find up from given cwd', function (t) { | ||
return new Promise(function ($return, $error) { | ||
var outer, cwd, actual; | ||
return Promise.resolve(_test.fix.bootstrap('fixtures/outer-scope')).then(function ($await_35) { | ||
try { | ||
outer = $await_35; | ||
return Promise.resolve(_test.git.init(_path2.default.join(outer, 'inner-scope'))).then(function ($await_36) { | ||
try { | ||
cwd = _path2.default.join(outer, 'inner-scope', 'child-scope'); | ||
t.deepEqual(actual, { | ||
extends: ['./first-extended'], | ||
rules: { | ||
zero: 0, | ||
one: 1, | ||
two: 2 | ||
} | ||
}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this))); | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_37) { | ||
try { | ||
actual = $await_37; | ||
(0, _ava2.default)('recursive extends with package.json file', t => new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/recursive-extends-package')).then(function ($await_25) { | ||
try { | ||
cwd = $await_25; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_26) { | ||
try { | ||
actual = $await_26; | ||
t.deepEqual(actual, { | ||
extends: [], | ||
rules: { | ||
child: true, | ||
inner: false, | ||
outer: false | ||
} | ||
}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this)); | ||
}); | ||
(0, _ava2.default)('find up config from outside current git repo', function (t) { | ||
return new Promise(function ($return, $error) { | ||
var outer, cwd, actual; | ||
return Promise.resolve(_test.fix.bootstrap('fixtures/outer-scope')).then(function ($await_38) { | ||
try { | ||
outer = $await_38; | ||
return Promise.resolve(_test.git.init(_path2.default.join(outer, 'inner-scope'))).then(function ($await_39) { | ||
try { | ||
cwd = $await_39; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_40) { | ||
try { | ||
actual = $await_40; | ||
t.deepEqual(actual, { | ||
extends: ['./first-extended'], | ||
rules: { | ||
zero: 0, | ||
one: 1, | ||
two: 2 | ||
} | ||
}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this))); | ||
t.deepEqual(actual, { | ||
extends: [], | ||
rules: { | ||
child: false, | ||
inner: false, | ||
outer: true | ||
} | ||
}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this)); | ||
}); | ||
(0, _ava2.default)('parser preset overwrites completely instead of merging', t => new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/parser-preset-override')).then(function ($await_27) { | ||
try { | ||
cwd = $await_27; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_28) { | ||
try { | ||
actual = $await_28; | ||
t.is(actual.parserPreset.name, './custom'); | ||
t.deepEqual(actual.parserPreset.parserOpts, { | ||
headerPattern: /.*/ | ||
}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this))); | ||
(0, _ava2.default)('recursive extends with parserPreset', t => new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/recursive-parser-preset')).then(function ($await_29) { | ||
try { | ||
cwd = $await_29; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_30) { | ||
try { | ||
actual = $await_30; | ||
t.is(actual.parserPreset.name, './conventional-changelog-custom'); | ||
t.is(typeof actual.parserPreset.parserOpts, 'object'); | ||
t.deepEqual(actual.parserPreset.parserOpts.headerPattern, /^(\w*)(?:\((.*)\))?-(.*)$/); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this))); | ||
(0, _ava2.default)('ignores unknow keys', t => new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/trash-file')).then(function ($await_31) { | ||
try { | ||
cwd = $await_31; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_32) { | ||
try { | ||
actual = $await_32; | ||
t.deepEqual(actual, { | ||
extends: [], | ||
rules: { | ||
foo: 'bar', | ||
baz: 'bar' | ||
} | ||
}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this))); | ||
(0, _ava2.default)('ignores unknow keys recursively', t => new Promise(function ($return, $error) { | ||
var cwd, actual; | ||
return Promise.resolve(_test.git.bootstrap('fixtures/trash-extend')).then(function ($await_33) { | ||
try { | ||
cwd = $await_33; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_34) { | ||
try { | ||
actual = $await_34; | ||
t.deepEqual(actual, { | ||
extends: ['./one'], | ||
rules: { | ||
zero: 0, | ||
one: 1 | ||
} | ||
}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this))); | ||
(0, _ava2.default)('find up from given cwd', t => new Promise(function ($return, $error) { | ||
var outer, cwd, actual; | ||
return Promise.resolve(_test.fix.bootstrap('fixtures/outer-scope')).then(function ($await_35) { | ||
try { | ||
outer = $await_35; | ||
return Promise.resolve(_test.git.init(_path2.default.join(outer, 'inner-scope'))).then(function ($await_36) { | ||
try { | ||
cwd = _path2.default.join(outer, 'inner-scope', 'child-scope'); | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_37) { | ||
try { | ||
actual = $await_37; | ||
t.deepEqual(actual, { | ||
extends: [], | ||
rules: { | ||
child: true, | ||
inner: false, | ||
outer: false | ||
} | ||
}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this))); | ||
(0, _ava2.default)('find up config from outside current git repo', t => new Promise(function ($return, $error) { | ||
var outer, cwd, actual; | ||
return Promise.resolve(_test.fix.bootstrap('fixtures/outer-scope')).then(function ($await_38) { | ||
try { | ||
outer = $await_38; | ||
return Promise.resolve(_test.git.init(_path2.default.join(outer, 'inner-scope'))).then(function ($await_39) { | ||
try { | ||
cwd = $await_39; | ||
return Promise.resolve((0, _2.default)({}, { cwd })).then(function ($await_40) { | ||
try { | ||
actual = $await_40; | ||
t.deepEqual(actual, { | ||
extends: [], | ||
rules: { | ||
child: false, | ||
inner: false, | ||
outer: true | ||
} | ||
}); | ||
return $return(); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
} catch ($boundEx) { | ||
return $error($boundEx); | ||
} | ||
}.bind(this), $error); | ||
}.bind(this))); | ||
//# sourceMappingURL=index.test.js.map |
{ | ||
"name": "@commitlint/load", | ||
"version": "6.1.3", | ||
"version": "7.0.0", | ||
"description": "Load shared commitlint configuration", | ||
@@ -62,7 +62,7 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@commitlint/test": "^6.1.3", | ||
"@commitlint/utils": "^6.1.3", | ||
"@commitlint/test": "^7.0.0", | ||
"@commitlint/utils": "^7.0.0", | ||
"ava": "0.22.0", | ||
"babel-cli": "6.26.0", | ||
"babel-preset-commitlint": "^6.1.3", | ||
"babel-preset-commitlint": "^7.0.0", | ||
"babel-register": "6.26.0", | ||
@@ -77,4 +77,4 @@ "concurrently": "3.5.1", | ||
"dependencies": { | ||
"@commitlint/execute-rule": "^6.1.3", | ||
"@commitlint/resolve-extends": "^6.1.3", | ||
"@commitlint/execute-rule": "^7.0.0", | ||
"@commitlint/resolve-extends": "^7.0.0", | ||
"babel-runtime": "^6.23.0", | ||
@@ -81,0 +81,0 @@ "cosmiconfig": "^4.0.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
43634
-5.93%650
-7.41%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed