Skip to content

Commit

Permalink
👌 IMPROVE: Format
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadawais committed Feb 14, 2020
1 parent ed59e80 commit 7c49798
Showing 1 changed file with 18 additions and 29 deletions.
47 changes: 18 additions & 29 deletions packages/create-guten-block/app/createPluginDir.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,34 @@

'use strict';

const chalk = require( 'chalk' );
const shell = require( 'shelljs' );
const clearConsole = require( './consoleClear' );
const directoryExists = require( 'directory-exists' );
const createGitignore = require( './createGitignore' );
const chalk = require('chalk');
const shell = require('shelljs');
const clearConsole = require('./consoleClear');
const directoryExists = require('directory-exists');
const createGitignore = require('./createGitignore');

module.exports = ( blockName, blockDir ) => {
module.exports = (blockName, blockDir) => {
// Check if the plugin dir is already presnet.
const dirAlreadyExist = directoryExists.sync( `./${ blockName }` );
const dirAlreadyExist = directoryExists.sync(`./${blockName}`);

// If exists then exit.
if ( dirAlreadyExist ) {
if (dirAlreadyExist) {
clearConsole();
console.log(
'\n❌ ',
chalk.black.bgRed(
` A directory with this name already exists: ${ blockName } \n`
)
);
console.log('\n❌ ', chalk.black.bgRed(` A directory with this name already exists: ${blockName} \n`));

console.log(
` ${ chalk.dim(
'Please move or delete it (maybe make a copy for backup) and run this command again.'
) }`
);
console.log(
` ${ chalk.dim( 'Or provide a different name for your block.' ) }`
);
console.log( chalk.dim( '\nFor example: \n' ) );
console.log(
` ${ chalk.dim( 'create-guten-block' ) } ${ chalk.green( 'new-block-name' ) }\n`
` ${chalk.dim('Please move or delete it (maybe make a copy for backup) and run this command again.')}`
);
process.exit( 1 );
console.log(` ${chalk.dim('Or provide a different name for your block.')}`);
console.log(chalk.dim('\nFor example: \n'));
console.log(` ${chalk.dim('create-guten-block')} ${chalk.green('new-block-name')}\n`);
process.exit(1);
} else {
return new Promise( async resolve => {
return new Promise(async resolve => {
// Where user is at the moment.
shell.mkdir( '-p', blockName );
await createGitignore( blockDir );
shell.mkdir('-p', blockName);
await createGitignore(blockDir);
resolve(true);
} );
});
}
};

0 comments on commit 7c49798

Please sign in to comment.