Skip to content

Commit 259716a

Browse files
Brian HannaAhmad Awais ⚡️
authored andcommitted
📦 NEW: Create default recommended .gitignore file on build
1 parent 8843dfc commit 259716a

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Install a starter .gitignore
3+
*/
4+
5+
'use strict';
6+
7+
const path = require( 'path' );
8+
const fs = require( 'fs-extra' );
9+
const shell = require( 'shelljs' );
10+
11+
module.exports = (blockDir) => {
12+
shell.cd( blockDir );
13+
shell.touch( '.gitignore' );
14+
15+
// Build a default .gitignore
16+
const ignore = `node_modules\ndist/`;
17+
18+
return new Promise( async resolve => {
19+
await fs.writeFileSync(
20+
path.join( process.cwd(), '.gitignore' ),
21+
ignore + '\n'
22+
);
23+
resolve( true );
24+
} );
25+
};

packages/create-guten-block/app/run.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const clearConsole = require( './consoleClear' );
1616
const updateNotifier = require( './updateNotifier' );
1717
const createPluginDir = require( './createPluginDir' );
1818
const npmInstallScripts = require( './npmInstallScripts' );
19+
const createGitignore = require( './createGitignore' );
1920

2021
module.exports = async() => {
2122
clearConsole();
@@ -26,7 +27,7 @@ module.exports = async() => {
2627
// 1. Set the CLI and get the blockName.
2728
const blockName = cli();
2829

29-
// 2. Build the block direcotry path.
30+
// 2. Build the block directory path.
3031
const blockDir = await getBlockDir( blockName );
3132

3233
// 2. Pre print.
@@ -42,6 +43,7 @@ module.exports = async() => {
4243
) }`
4344
);
4445
await createPluginDir( blockName );
46+
await createGitignore( blockDir );
4547
spinner.succeed();
4648

4749
// 4. NPM install cgb-scripts.

0 commit comments

Comments
 (0)