fix include/exclude option
This commit is contained in:
parent
c7629926e0
commit
7ec294133e
@ -109,6 +109,21 @@ exports[`dual 1`] = `
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`dual 2`] = `
|
||||||
|
{
|
||||||
|
"npm": {
|
||||||
|
"dependencies": {
|
||||||
|
"noty": {
|
||||||
|
"age": "5 years",
|
||||||
|
"info": "https://github.com/needim/noty",
|
||||||
|
"new": "3.2.0-beta",
|
||||||
|
"old": "3.1.0",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`exclude 1`] = `
|
exports[`exclude 1`] = `
|
||||||
{
|
{
|
||||||
"npm": {
|
"npm": {
|
||||||
@ -263,7 +278,7 @@ exports[`include 1`] = `
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`include 2 1`] = `
|
exports[`include 2`] = `
|
||||||
{
|
{
|
||||||
"npm": {
|
"npm": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -278,7 +293,7 @@ exports[`include 2 1`] = `
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`include 3 1`] = `
|
exports[`include 3`] = `
|
||||||
{
|
{
|
||||||
"npm": {
|
"npm": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
37
updates.js
37
updates.js
@ -760,17 +760,17 @@ async function main() {
|
|||||||
for (const file of resolveFiles) {
|
for (const file of resolveFiles) {
|
||||||
const projectDir = dirname(resolve(file));
|
const projectDir = dirname(resolve(file));
|
||||||
const filename = basename(file);
|
const filename = basename(file);
|
||||||
let config = {};
|
|
||||||
|
|
||||||
let mode;
|
let mode;
|
||||||
if (filename === "package.json") {
|
if (filename === "pyproject.toml") {
|
||||||
mode = "npm";
|
|
||||||
} else {
|
|
||||||
mode = "pypi";
|
mode = "pypi";
|
||||||
|
} else {
|
||||||
|
mode = "npm";
|
||||||
}
|
}
|
||||||
filePerMode[mode] = file;
|
filePerMode[mode] = file;
|
||||||
if (!deps[mode]) deps[mode] = {};
|
if (!deps[mode]) deps[mode] = {};
|
||||||
|
|
||||||
|
let config = {};
|
||||||
try {
|
try {
|
||||||
config = (await import(join(projectDir, "updates.config.js"))).default;
|
config = (await import(join(projectDir, "updates.config.js"))).default;
|
||||||
} catch {
|
} catch {
|
||||||
@ -779,6 +779,16 @@ async function main() {
|
|||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let includeCli, excludeCli;
|
||||||
|
if (args.include && args.include !== true) { // cli
|
||||||
|
includeCli = (Array.isArray(args.include) ? args.include : [args.include]).flatMap(item => item.split(","));
|
||||||
|
}
|
||||||
|
if (args.exclude && args.exclude !== true) {
|
||||||
|
excludeCli = (Array.isArray(args.exclude) ? args.exclude : [args.exclude]).flatMap(item => item.split(","));
|
||||||
|
}
|
||||||
|
const include = matchersToRegexSet(includeCli, config?.include);
|
||||||
|
const exclude = matchersToRegexSet(excludeCli, config?.exclude);
|
||||||
|
|
||||||
const agentOpts = {};
|
const agentOpts = {};
|
||||||
if (mode === "npm") {
|
if (mode === "npm") {
|
||||||
if (npmrc["strict-ssl"] === false) {
|
if (npmrc["strict-ssl"] === false) {
|
||||||
@ -835,17 +845,6 @@ async function main() {
|
|||||||
throw new Error(`Error parsing ${file}: ${err.message}`);
|
throw new Error(`Error parsing ${file}: ${err.message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
let includeCli, excludeCli;
|
|
||||||
if (args.include && args.include !== true) { // cli
|
|
||||||
includeCli = (Array.isArray(args.include) ? args.include : [args.include]).flatMap(item => item.split(","));
|
|
||||||
}
|
|
||||||
if (args.exclude && args.exclude !== true) {
|
|
||||||
excludeCli = (Array.isArray(args.exclude) ? args.exclude : [args.exclude]).flatMap(item => item.split(","));
|
|
||||||
}
|
|
||||||
|
|
||||||
const include = matchersToRegexSet(includeCli, config?.include);
|
|
||||||
const exclude = matchersToRegexSet(excludeCli, config?.exclude);
|
|
||||||
|
|
||||||
for (const depType of dependencyTypes) {
|
for (const depType of dependencyTypes) {
|
||||||
let obj;
|
let obj;
|
||||||
if (mode === "npm") {
|
if (mode === "npm") {
|
||||||
@ -872,11 +871,7 @@ async function main() {
|
|||||||
numDependencies += Object.keys(maybeUrlDeps).length;
|
numDependencies += Object.keys(maybeUrlDeps).length;
|
||||||
|
|
||||||
if (!Object.keys(deps[mode]).length && !Object.keys(maybeUrlDeps).length) {
|
if (!Object.keys(deps[mode]).length && !Object.keys(maybeUrlDeps).length) {
|
||||||
if (include.size || exclude.size) {
|
continue;
|
||||||
throw new Error(`No dependencies match the given include/exclude filters`);
|
|
||||||
} else {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let registry;
|
let registry;
|
||||||
@ -957,7 +952,7 @@ async function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (numDependencies === 0) {
|
if (numDependencies === 0) {
|
||||||
console.info("No dependencies present, nothing to do");
|
console.info("No dependencies found, nothing to do");
|
||||||
doExit();
|
doExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,11 +171,12 @@ test("prerelease", makeTest("-j -g -p"));
|
|||||||
test("release", makeTest("-j -R"));
|
test("release", makeTest("-j -R"));
|
||||||
test("patch", makeTest("-j -P"));
|
test("patch", makeTest("-j -P"));
|
||||||
test("include", makeTest("-j -i noty"));
|
test("include", makeTest("-j -i noty"));
|
||||||
test("include 2", makeTest("-j -i noty -i noty,noty"));
|
test("include", makeTest("-j -i noty -i noty,noty"));
|
||||||
test("include 3", makeTest("-j -i /^noty/"));
|
test("include", makeTest("-j -i /^noty/"));
|
||||||
test("exclude", makeTest("-j -e gulp-sourcemaps,prismjs,svgstore,html-webpack-plugin,noty,jpeg-buffer-orientation,styled-components,@babel/preset-env,versions/updates,react"));
|
test("exclude", makeTest("-j -e gulp-sourcemaps,prismjs,svgstore,html-webpack-plugin,noty,jpeg-buffer-orientation,styled-components,@babel/preset-env,versions/updates,react"));
|
||||||
test("exclude", makeTest("-j -e gulp-sourcemaps -i /react/"));
|
test("exclude", makeTest("-j -e gulp-sourcemaps -i /react/"));
|
||||||
test("exclude", makeTest("-j -i gulp*"));
|
test("exclude", makeTest("-j -i gulp*"));
|
||||||
test("exclude", makeTest("-j -i /^gulp/ -P gulp*"));
|
test("exclude", makeTest("-j -i /^gulp/ -P gulp*"));
|
||||||
test("pypi", makeTest(`-j -f ${poetryFile}`));
|
test("pypi", makeTest(`-j -f ${poetryFile}`));
|
||||||
test("dual", makeTest(`-j -f ${dualFile}`));
|
test("dual", makeTest(`-j -f ${dualFile}`));
|
||||||
|
test("dual", makeTest(`-j -f ${dualFile} -i noty`));
|
||||||
|
Loading…
Reference in New Issue
Block a user