Skip to content

Commit

Permalink
Merge pull request #133 from loopline-systems/feature/130-improve-err…
Browse files Browse the repository at this point in the history
…or-handling

Feature/130 improve error handling
  • Loading branch information
stefanjudis committed Feb 8, 2016
2 parents 0f33f6e + 45786f8 commit 38aef30
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
10 changes: 10 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ var Builder = {
return callback( new Error( 'Required option not set' ) );
}

// FAIL when no configuration for desired platform is found
if (
! options.config[ options.platform ]
) {
return callback( new Error(
'No config property found for `' + options.platform + '`.\n' +
'Please check your configuration file and the documentation.'
) );
}

// Make sure appPath is absolute
options.appPath = path.resolve( options.appPath );

Expand Down
20 changes: 18 additions & 2 deletions index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ test( 'Builder.init().build - call the correct platform', function( t ) {
appPath : 'foo',
basePath : 'bar',
platform : 'bar',
config : {},
config : { bar : {} },
log : function() {}
},
function( error, result ) {
Expand Down Expand Up @@ -104,7 +104,7 @@ test( 'Builder.init().build - create output directory if not present', function(
} );

test( 'Builder.init().build - check for required options', function( t ) {
t.plan( 4 );
t.plan( 5 );

var Builder = proxyquireStrict(
'./index.js',
Expand Down Expand Up @@ -160,4 +160,20 @@ test( 'Builder.init().build - check for required options', function( t ) {
t.equal( error.message, 'Required option not set' );
}
);

Builder.init().build(
{
appPath : 'foo',
config : {},
basePath : 'bar',
platform : 'baz',
log : function() {}
},
function( error ) {
t.equal(
error.message,
'No config property found for `baz`.\nPlease check your configuration file and the documentation.'
);
}
);
} );
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "electron-builder",
"version": "2.6.0",
"version": "2.7.1",
"description": "Create electron apps installers the easy way",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 38aef30

Please sign in to comment.