From 97c617ee34bd0d54b91141f33250d44830a93dd2 Mon Sep 17 00:00:00 2001 From: Matt Hinchliffe Date: Thu, 14 Feb 2019 14:27:43 +0000 Subject: [PATCH 1/3] =?UTF-8?q?Ignore=20glob=20matches=20which=20are=20not?= =?UTF-8?q?=20directories=20containing=20a=20package.json=20file=20=20?= =?UTF-8?q?=F0=9F=90=BF=20v2.10.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/load-manifest.js | 6 +++++- src/load-packages.js | 10 ++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/load-manifest.js b/src/load-manifest.js index 4deb7b0..3071410 100644 --- a/src/load-manifest.js +++ b/src/load-manifest.js @@ -1,6 +1,10 @@ +const fs = require('fs'); const path = require('path'); module.exports = (packagePath) => { const manifestPath = path.resolve(packagePath, 'package.json'); - return require(manifestPath); + + if (fs.existsSync(manifestPath)) { + return require(manifestPath); + } }; diff --git a/src/load-packages.js b/src/load-packages.js index bd3bad4..dc0a9a8 100644 --- a/src/load-packages.js +++ b/src/load-packages.js @@ -4,9 +4,15 @@ const loadManifest = require('./load-manifest'); module.exports = async (globs = []) => { const locations = await getPackages(globs); + const packages = [] - return locations.map((location) => { + locations.forEach((location) => { const manifest = loadManifest(location); - return new Package(manifest, location); + + if (manifest) { + packages.push(new Package(manifest, location)); + } }); + + return packages }; From 19535f94f4c0baca8e82ed13677aaa10be16dcce Mon Sep 17 00:00:00 2001 From: Matt Hinchliffe Date: Thu, 14 Feb 2019 14:39:39 +0000 Subject: [PATCH 2/3] =?UTF-8?q?Ensure=20exit=20codes=20are=20always=20numb?= =?UTF-8?q?ers=20=20=F0=9F=90=BF=20v2.10.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cli-task.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli-task.js b/src/cli-task.js index f4d8ce1..3b3b39e 100644 --- a/src/cli-task.js +++ b/src/cli-task.js @@ -46,7 +46,7 @@ module.exports = (task) => { logger.message(`Tasks complete, took ${timer.duration}s`); } catch (error) { const message = error instanceof Error ? error.message : error; - const exitCode = error.code || 1; + const exitCode = Number.isInteger(error.code) ? error.code : 1; logger.error(`Task failed: "${message}"`); process.exit(exitCode); From 9c8168f78c868301dd5f56d0e2798487a3672008 Mon Sep 17 00:00:00 2001 From: Matt Hinchliffe Date: Thu, 14 Feb 2019 14:49:55 +0000 Subject: [PATCH 3/3] =?UTF-8?q?Create=20an=20explicit=20error=20when=20dir?= =?UTF-8?q?ectories=20are=20matched=20without=20a=20package.json=20file=20?= =?UTF-8?q?=20=F0=9F=90=BF=20v2.10.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/load-manifest.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/load-manifest.js b/src/load-manifest.js index 3071410..4a611d5 100644 --- a/src/load-manifest.js +++ b/src/load-manifest.js @@ -2,9 +2,15 @@ const fs = require('fs'); const path = require('path'); module.exports = (packagePath) => { - const manifestPath = path.resolve(packagePath, 'package.json'); + const stats = fs.statSync(packagePath); - if (fs.existsSync(manifestPath)) { - return require(manifestPath); + if (stats.isDirectory()) { + const manifestPath = path.resolve(packagePath, 'package.json'); + + if (fs.existsSync(manifestPath)) { + return require(manifestPath); + } else { + throw Error(`Folder found without package.json file: ${packagePath}`) + } } };