Skip to content

Commit

Permalink
Wrap bundler in a try to catch unexpected bundle time error. This fix…
Browse files Browse the repository at this point in the history
…es template syntax errors killing the whole app.
  • Loading branch information
n1mmy committed Apr 7, 2012
1 parent 1a503d1 commit 6bed875
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions app/lib/bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -613,29 +613,33 @@ _.extend(Bundle.prototype, {
exports.bundle = function (project_dir, output_path, options) {
options = options || {};

// Create a bundle, add the project
packages.flush();
var bundle = new Bundle;
var project = packages.get_for_dir(project_dir, ignore_files);
bundle.use(project);

// Include tests if requested
if (options.include_tests) {
// in the future, let use specify the driver, instead of hardcoding?
bundle.use(packages.get('test-in-browser'));
bundle.include_tests(project);
}
try {
// Create a bundle, add the project
packages.flush();
var bundle = new Bundle;
var project = packages.get_for_dir(project_dir, ignore_files);
bundle.use(project);

// Include tests if requested
if (options.include_tests) {
// in the future, let use specify the driver, instead of hardcoding?
bundle.use(packages.get('test-in-browser'));
bundle.include_tests(project);
}

// Minify, if requested
if (!options.no_minify)
bundle.minify();
// Minify, if requested
if (!options.no_minify)
bundle.minify();

// Write to disk
var dev_bundle_mode =
options.skip_dev_bundle ? "skip" : (
options.symlink_dev_bundle ? "symlink" : "copy");
bundle.write_to_directory(output_path, project_dir, dev_bundle_mode);
// Write to disk
var dev_bundle_mode =
options.skip_dev_bundle ? "skip" : (
options.symlink_dev_bundle ? "symlink" : "copy");
bundle.write_to_directory(output_path, project_dir, dev_bundle_mode);

if (bundle.errors.length)
return bundle.errors;
if (bundle.errors.length)
return bundle.errors;
} catch (err) {
return ["Exception while bundling application:\n" + (err.stack || err)];
}
};

0 comments on commit 6bed875

Please sign in to comment.