Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Ignore glob matches which are not directories containing a package.json #30

Merged
merged 3 commits into from
Feb 14, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion src/cli-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 12 additions & 2 deletions src/load-manifest.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
const fs = require('fs');
const path = require('path');

module.exports = (packagePath) => {
const manifestPath = path.resolve(packagePath, 'package.json');
return require(manifestPath);
const stats = fs.statSync(packagePath);

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}`)
}
}
};
10 changes: 8 additions & 2 deletions src/load-packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};