Skip to content

Commit

Permalink
Merge pull request #10 from userfrosting/develop
Browse files Browse the repository at this point in the history
Option to silently ignore failures
  • Loading branch information
Silic0nS0ldier authored Apr 18, 2020
2 parents 65d8814 + 82e2440 commit 999ca96
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added
- Option to silently ignore errors, effectively skipping dependencies which cannot be processed.

## [3.0.0] - 2020-03-14

### Fixed
Expand Down
5 changes: 4 additions & 1 deletion src/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ test.serial("Throws when attempting to browserify non existant dependency", asyn
);
});

test.todo("Throws when attempting to browserify dependency with malformed input file");
test.todo("Throws when attempting to browserify dependency with malformed input file without silent flag");

test.todo("Doesn't throw when attempting to browserify dependency with malformed input file without silent flag");

// NOTE: Silent failures offers an alternative handling here, do we want to remove support?
test.todo("Successfully runs against dependencies with an array for main");
18 changes: 16 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,15 @@ export default async function (userOptions: IOptions): Promise<void> {
if (ex.code !== "EEXIST") throw ex;
}

// Add to queue
await BrowserifyDependency(depName, targetPath, depOptions);
// Process dependency
try {
await BrowserifyDependency(depName, targetPath, depOptions);
} catch (error) {
if (!depOptions.silentFailures) {
// Errors not silenced, interrupt processing.
throw error;
}
}
}
}

Expand Down Expand Up @@ -112,6 +119,11 @@ export interface IOptions {
* Path to output directory.
*/
outputDir: string;

/**
* Silently ignore failed browserify runs.
*/
silentFailures?: boolean;
}

/**
Expand All @@ -122,6 +134,7 @@ class Options implements IOptions {
dependencies: string[];
inputDir: string;
outputDir: string;
silentFailures: boolean;

/**
* @param userOptions User options to build instance from.
Expand All @@ -131,6 +144,7 @@ class Options implements IOptions {
this.dependencies = userOptions.dependencies;
this.inputDir = userOptions.inputDir;
this.outputDir = userOptions.outputDir;
this.silentFailures = userOptions.silentFailures ?? false;
}

/**
Expand Down

0 comments on commit 999ca96

Please sign in to comment.