|
7 | 7 |
|
8 | 8 | 'use strict'; |
9 | 9 |
|
10 | | -const chalk = require( 'chalk' ); |
11 | | -const shell = require( 'shelljs' ); |
12 | | -const clearConsole = require( './consoleClear' ); |
13 | | -const directoryExists = require( 'directory-exists' ); |
14 | | -const createGitignore = require( './createGitignore' ); |
| 10 | +const chalk = require('chalk'); |
| 11 | +const shell = require('shelljs'); |
| 12 | +const clearConsole = require('./consoleClear'); |
| 13 | +const directoryExists = require('directory-exists'); |
| 14 | +const createGitignore = require('./createGitignore'); |
15 | 15 |
|
16 | | -module.exports = ( blockName, blockDir ) => { |
| 16 | +module.exports = (blockName, blockDir) => { |
17 | 17 | // Check if the plugin dir is already presnet. |
18 | | - const dirAlreadyExist = directoryExists.sync( `./${ blockName }` ); |
| 18 | + const dirAlreadyExist = directoryExists.sync(`./${blockName}`); |
19 | 19 |
|
20 | 20 | // If exists then exit. |
21 | | - if ( dirAlreadyExist ) { |
| 21 | + if (dirAlreadyExist) { |
22 | 22 | clearConsole(); |
23 | | - console.log( |
24 | | - '\n❌ ', |
25 | | - chalk.black.bgRed( |
26 | | - ` A directory with this name already exists: ${ blockName } \n` |
27 | | - ) |
28 | | - ); |
| 23 | + console.log('\n❌ ', chalk.black.bgRed(` A directory with this name already exists: ${blockName} \n`)); |
29 | 24 |
|
30 | 25 | console.log( |
31 | | - ` ${ chalk.dim( |
32 | | - 'Please move or delete it (maybe make a copy for backup) and run this command again.' |
33 | | - ) }` |
34 | | - ); |
35 | | - console.log( |
36 | | - ` ${ chalk.dim( 'Or provide a different name for your block.' ) }` |
37 | | - ); |
38 | | - console.log( chalk.dim( '\nFor example: \n' ) ); |
39 | | - console.log( |
40 | | - ` ${ chalk.dim( 'create-guten-block' ) } ${ chalk.green( 'new-block-name' ) }\n` |
| 26 | + ` ${chalk.dim('Please move or delete it (maybe make a copy for backup) and run this command again.')}` |
41 | 27 | ); |
42 | | - process.exit( 1 ); |
| 28 | + console.log(` ${chalk.dim('Or provide a different name for your block.')}`); |
| 29 | + console.log(chalk.dim('\nFor example: \n')); |
| 30 | + console.log(` ${chalk.dim('create-guten-block')} ${chalk.green('new-block-name')}\n`); |
| 31 | + process.exit(1); |
43 | 32 | } else { |
44 | | - return new Promise( async resolve => { |
| 33 | + return new Promise(async resolve => { |
45 | 34 | // Where user is at the moment. |
46 | | - shell.mkdir( '-p', blockName ); |
47 | | - await createGitignore( blockDir ); |
| 35 | + shell.mkdir('-p', blockName); |
| 36 | + await createGitignore(blockDir); |
48 | 37 | resolve(true); |
49 | | - } ); |
| 38 | + }); |
50 | 39 | } |
51 | 40 | }; |
0 commit comments