diff --git a/snapshots/updates.test.js.snap b/snapshots/updates.test.js.snap index 32fc145..6c39644 100644 --- a/snapshots/updates.test.js.snap +++ b/snapshots/updates.test.js.snap @@ -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`] = ` { "npm": { @@ -263,7 +278,7 @@ exports[`include 1`] = ` } `; -exports[`include 2 1`] = ` +exports[`include 2`] = ` { "npm": { "dependencies": { @@ -278,7 +293,7 @@ exports[`include 2 1`] = ` } `; -exports[`include 3 1`] = ` +exports[`include 3`] = ` { "npm": { "dependencies": { diff --git a/updates.js b/updates.js index 41e7c3a..d05c338 100755 --- a/updates.js +++ b/updates.js @@ -760,17 +760,17 @@ async function main() { for (const file of resolveFiles) { const projectDir = dirname(resolve(file)); const filename = basename(file); - let config = {}; let mode; - if (filename === "package.json") { - mode = "npm"; - } else { + if (filename === "pyproject.toml") { mode = "pypi"; + } else { + mode = "npm"; } filePerMode[mode] = file; if (!deps[mode]) deps[mode] = {}; + let config = {}; try { config = (await import(join(projectDir, "updates.config.js"))).default; } catch { @@ -779,6 +779,16 @@ async function main() { } 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 = {}; if (mode === "npm") { if (npmrc["strict-ssl"] === false) { @@ -835,17 +845,6 @@ async function main() { 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) { let obj; if (mode === "npm") { @@ -872,11 +871,7 @@ async function main() { numDependencies += Object.keys(maybeUrlDeps).length; if (!Object.keys(deps[mode]).length && !Object.keys(maybeUrlDeps).length) { - if (include.size || exclude.size) { - throw new Error(`No dependencies match the given include/exclude filters`); - } else { - continue; - } + continue; } let registry; @@ -957,7 +952,7 @@ async function main() { } if (numDependencies === 0) { - console.info("No dependencies present, nothing to do"); + console.info("No dependencies found, nothing to do"); doExit(); } diff --git a/updates.test.js b/updates.test.js index a481bca..e215530 100644 --- a/updates.test.js +++ b/updates.test.js @@ -171,11 +171,12 @@ test("prerelease", makeTest("-j -g -p")); test("release", makeTest("-j -R")); test("patch", makeTest("-j -P")); test("include", makeTest("-j -i noty")); -test("include 2", makeTest("-j -i noty -i noty,noty")); -test("include 3", makeTest("-j -i /^noty/")); +test("include", makeTest("-j -i noty -i noty,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 -i /react/")); test("exclude", makeTest("-j -i gulp*")); test("exclude", makeTest("-j -i /^gulp/ -P gulp*")); test("pypi", makeTest(`-j -f ${poetryFile}`)); test("dual", makeTest(`-j -f ${dualFile}`)); +test("dual", makeTest(`-j -f ${dualFile} -i noty`));