Skip to content

Commit

Permalink
Minor improvements in the code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamil Piechaczek committed Sep 10, 2018
1 parent f4368ea commit b829f31
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 30 deletions.
6 changes: 2 additions & 4 deletions lib/commands/diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,10 @@ module.exports = {
return execCommand.execute( getExecData( diffCommand ) )
.then( execResponse => {
if ( !execResponse.logs.info.length ) {
return Promise.resolve( {} );
return {};
}

return Promise.resolve( {
logs: execResponse.logs
} );
return execResponse;
} );

function getExecData( command ) {
Expand Down
4 changes: 1 addition & 3 deletions lib/commands/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ module.exports = {

log.info( 'Repository is up-to-date.' );

return Promise.resolve( {
logs: log.all()
} );
return { logs: log.all() };
} );

function getExecData( command ) {
Expand Down
37 changes: 19 additions & 18 deletions lib/commands/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,27 @@ module.exports = {
.then( execResponse => execResponse.logs.info[ 0 ].slice( 0, 7 ) );
}

return promise.then( dataToSave => {
const commandResponse = {
packageName: data.packageName,
data: dataToSave,
branch: options.branch,
hash: options.hash
};

/* istanbul ignore else */
if ( options.branch ) {
log.info( `Branch: "${ dataToSave }".` );
} else if ( options.hash ) {
log.info( `Commit: "${ dataToSave }".` );
}
return promise
.then( dataToSave => {
const commandResponse = {
packageName: data.packageName,
data: dataToSave,
branch: options.branch,
hash: options.hash
};

/* istanbul ignore else */
if ( options.branch ) {
log.info( `Branch: "${ dataToSave }".` );
} else if ( options.hash ) {
log.info( `Commit: "${ dataToSave }".` );
}

return Promise.resolve( {
response: commandResponse,
logs: log.all()
return {
response: commandResponse,
logs: log.all()
};
} );
} );

function getExecData( command ) {
return Object.assign( {}, data, {
Expand Down
4 changes: 1 addition & 3 deletions lib/commands/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ module.exports = {
mgitBranch: data.repository.branch
};

return Promise.resolve( {
response: commandResponse
} );
return { response: commandResponse };
} );

function getExecData( command ) {
Expand Down
8 changes: 6 additions & 2 deletions lib/commands/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ module.exports = {
if ( isOnBranchRegexp.test( stdout ) ) {
log.info( `Package "${ data.packageName }" is on a detached commit.` );

return Promise.resolve( { logs: log.all() } );
return { logs: log.all() };
}

return execCommand.execute( getExecData( `git pull origin ${ data.repository.branch }` ) )
.then( response => {
log.concat( response.logs );

return Promise.resolve( { logs: log.all() } );
return { logs: log.all() };
} );
} )
.catch( commandResponseOrError => {
Expand Down Expand Up @@ -127,6 +127,10 @@ module.exports = {
/**
* @private
* @param {Object} packageDetails
* @param {String} packageDetails.name A name of the package.
* @param {String} packageDetails.url A url that will be cloned.
* @param {String} packageDetails.path An absolute path where the package should be cloned.
* @param {String} packageDetails.branch A branch on which the repository will be checked out after cloning.
* @param {Object} options Command options.
* @returns {Promise}
*/
Expand Down

0 comments on commit b829f31

Please sign in to comment.