Skip to content

Commit

Permalink
Standardize alerts for import commands
Browse files Browse the repository at this point in the history
Use the displayNotice util
  • Loading branch information
mjangda committed Jan 11, 2017
1 parent c070688 commit 459470d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/bin/vip-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ program
return console.error( 'Invalid uploads directory. Uploads must be in uploads/' );
}

utils.findAndConfirmSite( site, site => {
utils.findAndConfirmSite( site, 'Importing files for site:', site => {
api
.get( '/sites/' + site.client_site_id + '/meta/files_access_token' )
.end( ( err, res ) => {
Expand Down Expand Up @@ -177,7 +177,7 @@ program
throttle: options.throttle,
};

utils.findAndConfirmSite( site, site => {
utils.findAndConfirmSite( site, 'Importing SQL for site:', site => {
db.importDB( site, file, opts, err => {
if ( err ) {
return console.error( err );
Expand Down
10 changes: 6 additions & 4 deletions src/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export function findSite( domain, cb ) {
});
}

export function findAndConfirmSite( site, cb ) {
export function findAndConfirmSite( site, action, cb ) {
findSite( site, ( err, s ) => {
if ( err ) {
return console.error( err );
Expand All @@ -119,9 +119,11 @@ export function findAndConfirmSite( site, cb ) {
return console.error( "Couldn't find site:", site );
}

console.log( "Client Site:", s.client_site_id );
console.log( "Primary Domain:", s.domain_name );
console.log( "Environment:", s.environment_name );
displayNotice( [
action,
`-- Site: ${ s.domain_name } (#${ s.client_site_id })`,
'-- Environment: ' + s.environment_name,
] );

promptly.confirm( "Are you sure?", ( err, yes ) => {
if ( err ) {
Expand Down

0 comments on commit 459470d

Please sign in to comment.