Skip to content

Commit 89e3cf5

Browse files
author
Ahmad Awais
committed
📦 NEW: Build Scripts
1 parent a275849 commit 89e3cf5

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

  • packages/cgb-scripts/scripts

‎packages/cgb-scripts/scripts/init.js‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
const ora = require( 'ora' );
1212
const path = require( 'path' );
1313
const chalk = require( 'chalk' );
14+
const execa = require( 'execa' );
1415
const shell = require( 'shelljs' );
1516

1617
// Makes the script crash on unhandled rejections instead of silently
@@ -134,6 +135,26 @@ const printNextSteps = ( blockName, blockDir ) => {
134135
);
135136
};
136137

138+
/**
139+
* NPM install cgb-scripts.
140+
*
141+
* - Build package.json file.
142+
* - NPM install the plugin block.
143+
*
144+
* @param {string} blockDir The block directory.
145+
* @return {promise} promise resolved.
146+
*/
147+
148+
const buildBlockScripts = blockDir => {
149+
shell.cd( blockDir );
150+
151+
// Build the scripts.
152+
return new Promise( async resolve => {
153+
await execa( 'npm', [ 'run', 'build' ] );
154+
resolve( true );
155+
} );
156+
};
157+
137158
/**
138159
* Initializer function.
139160
*
@@ -168,4 +189,9 @@ module.exports = async( root, blockName, blockDir ) => {
168189

169190
// 2. Prints next steps.
170191
await printNextSteps( blockName, blockDir );
192+
193+
// 3. Build scripts.
194+
spinner.start( '4. Building block scripts...' );
195+
await buildBlockScripts( blockDir );
196+
spinner.succeed();
171197
};

0 commit comments

Comments
 (0)