Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 7 additions & 17 deletions bin/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,33 @@
/* eslint no-console: 0 */

/**
* Theme setup; thin wrapper that delegates to the shared scaffold engine from
* rtcamp/wp-framework, passing this theme's bin/scaffold.config.js.
* Theme setup; thin wrapper that delegates to the shared init engine in
* @rtcamp/wp-tooling, passing this theme's bin/scaffold.config.js.
*
* Requires `composer install` and `npm install`. Invoke with `npm run init`.
* Requires `npm install`. Invoke with `npm run init`.
*/

/**
* External dependencies
*/
const fs = require( 'fs' );
const path = require( 'path' );

/**
* Internal dependencies
*/
const config = require( './scaffold.config' );

const root = path.resolve( __dirname, '..' );
const enginePath = path.join( root, 'vendor', 'rtcamp', 'wp-framework', 'bin', 'scaffold.js' );

if ( ! fs.existsSync( enginePath ) ) {
console.error( '\nScaffold engine not found at vendor/rtcamp/wp-framework.' );
console.error( 'Run `composer install` first, then `npm run init`.\n' );
process.exit( 1 );
}

let run;
try {
( { run } = require( enginePath ) );
( { run } = require( '@rtcamp/wp-tooling/init' ) );
} catch ( err ) {
console.error( '\nCould not load the scaffold engine.' );
console.error( 'Ensure dependencies are installed (`composer install` && `npm install`).\n' );
console.error( '\nCould not load the init engine from @rtcamp/wp-tooling.' );
console.error( 'Ensure dependencies are installed (`npm install`).\n' );
console.error( err.message );
process.exit( 1 );
}

run( config, { root } )
run( config, { root: path.resolve( __dirname, '..' ) } )
.then( () => process.exit( process.exitCode || 0 ) )
.catch( ( err ) => {
console.error( err );
Expand Down
Loading