Skip to content

Commit 8b113a3

Browse files
committed
Format build files
1 parent 034169d commit 8b113a3

File tree

3 files changed

+284
-116
lines changed

3 files changed

+284
-116
lines changed

tools/gutenberg/build-gutenberg.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,13 @@ function exec( command, args, options = {} ) {
6262
console.error( '\nCommand errors:' );
6363
console.error( stderr );
6464
}
65-
reject( new Error( `${ command } ${ args.join( ' ' ) } failed with code ${ code }` ) );
65+
reject(
66+
new Error(
67+
`${ command } ${ args.join(
68+
' '
69+
) } failed with code ${ code }`
70+
)
71+
);
6672
} else {
6773
resolve();
6874
}
@@ -116,7 +122,10 @@ async function main() {
116122
console.log( ' ✅ IS_GUTENBERG_PLUGIN = false' );
117123
console.log( ' ✅ IS_WORDPRESS_CORE = true' );
118124
} catch ( error ) {
119-
console.error( '❌ Error modifying Gutenberg package.json:', error.message );
125+
console.error(
126+
'❌ Error modifying Gutenberg package.json:',
127+
error.message
128+
);
120129
process.exit( 1 );
121130
}
122131

@@ -129,11 +138,14 @@ async function main() {
129138
try {
130139
// On Windows, shell mode is used and needs the argument wrapped in quotes
131140
// On Unix, arguments are passed directly without shell parsing
132-
const baseUrlArg = process.platform === 'win32'
133-
? '--base-url="includes_url( \'build\' )"'
134-
: '--base-url=includes_url( \'build\' )';
141+
const baseUrlArg =
142+
process.platform === 'win32'
143+
? '--base-url="includes_url( \'build\' )"'
144+
: "--base-url=includes_url( 'build' )";
135145

136-
await exec( 'npm', [ 'run', 'build', '--', baseUrlArg ], { cwd: gutenbergDir } );
146+
await exec( 'npm', [ 'run', 'build', '--', baseUrlArg ], {
147+
cwd: gutenbergDir,
148+
} );
137149

138150
const duration = Math.round( ( Date.now() - startTime ) / 1000 );
139151
console.log( `✅ Build completed in ${ duration }s` );

tools/gutenberg/checkout-gutenberg.js

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@ function exec( command, args, options = {} ) {
7272
console.error( '\nCommand errors:' );
7373
console.error( stderr );
7474
}
75-
reject( new Error( `${ command } ${ args.join( ' ' ) } failed with code ${ code }` ) );
75+
reject(
76+
new Error(
77+
`${ command } ${ args.join(
78+
' '
79+
) } failed with code ${ code }`
80+
)
81+
);
7682
} else {
7783
resolve();
7884
}
@@ -134,7 +140,9 @@ async function main() {
134140
// Read Gutenberg ref from package.json
135141
let ref;
136142
try {
137-
const packageJson = JSON.parse( fs.readFileSync( packageJsonPath, 'utf8' ) );
143+
const packageJson = JSON.parse(
144+
fs.readFileSync( packageJsonPath, 'utf8' )
145+
);
138146
ref = packageJson.gutenberg?.ref;
139147

140148
if ( ! ref ) {
@@ -156,13 +164,24 @@ async function main() {
156164
try {
157165
// Generic shallow clone approach that works for both branches and commit hashes
158166
// 1. Clone with no checkout and shallow depth
159-
await exec( 'git', [ 'clone', '--depth', '1', '--no-checkout', GUTENBERG_REPO, 'gutenberg' ] );
167+
await exec( 'git', [
168+
'clone',
169+
'--depth',
170+
'1',
171+
'--no-checkout',
172+
GUTENBERG_REPO,
173+
'gutenberg',
174+
] );
160175

161176
// 2. Fetch the specific ref with depth 1 (works for branches, tags, and commits)
162-
await exec( 'git', [ 'fetch', '--depth', '1', 'origin', ref ], { cwd: gutenbergDir } );
177+
await exec( 'git', [ 'fetch', '--depth', '1', 'origin', ref ], {
178+
cwd: gutenbergDir,
179+
} );
163180

164181
// 3. Checkout FETCH_HEAD
165-
await exec( 'git', [ 'checkout', 'FETCH_HEAD' ], { cwd: gutenbergDir } );
182+
await exec( 'git', [ 'checkout', 'FETCH_HEAD' ], {
183+
cwd: gutenbergDir,
184+
} );
166185

167186
console.log( '✅ Cloned successfully' );
168187
} catch ( error ) {
@@ -177,10 +196,14 @@ async function main() {
177196
console.log( `\n📡 Fetching and checking out: ${ ref }` );
178197
try {
179198
// Fetch the specific ref (works for branches, tags, and commit hashes)
180-
await exec( 'git', [ 'fetch', '--depth', '1', 'origin', ref ], { cwd: gutenbergDir } );
199+
await exec( 'git', [ 'fetch', '--depth', '1', 'origin', ref ], {
200+
cwd: gutenbergDir,
201+
} );
181202

182203
// Checkout what was just fetched
183-
await exec( 'git', [ 'checkout', 'FETCH_HEAD' ], { cwd: gutenbergDir } );
204+
await exec( 'git', [ 'checkout', 'FETCH_HEAD' ], {
205+
cwd: gutenbergDir,
206+
} );
184207

185208
console.log( '✅ Checked out successfully' );
186209
} catch ( error ) {
@@ -190,7 +213,9 @@ async function main() {
190213

191214
// Install dependencies
192215
console.log( '\n📦 Installing dependencies...' );
193-
const nodeModulesExists = fs.existsSync( path.join( gutenbergDir, 'node_modules' ) );
216+
const nodeModulesExists = fs.existsSync(
217+
path.join( gutenbergDir, 'node_modules' )
218+
);
194219

195220
if ( ! nodeModulesExists ) {
196221
console.log( ' (This may take a few minutes on first run)' );

0 commit comments

Comments
 (0)