1
- // scripts/build-and-copy.js
2
- const { exec } = require ( 'child_process' ) ;
3
- const fs = require ( 'fs' ) ;
4
- const path = require ( 'path' ) ;
5
1
6
- // Define paths relative to the root directory
7
- const rootDir = path . resolve ( __dirname , '..' ) ;
8
- const srcFile = path . join ( rootDir , 'dist/js/footer_scripts.min.js' ) ;
9
- const destFile = path . join ( rootDir , 'src/bundle-script.min.js' ) ;
2
+ const { exec } = require ( "child_process" ) ;
3
+ const fs = require ( "fs" ) ;
4
+ const path = require ( "path" ) ;
5
+
6
+ const rootDir = path . resolve ( __dirname , ".." ) ;
7
+ const srcFile = path . join ( rootDir , "dist/js/footer_scripts.min.js" ) ;
8
+ const destFile = path . join ( rootDir , "src/bundle-script.min.js" ) ;
10
9
11
10
// Step 1: Run the build command
12
- exec ( ' npm run build' , { cwd : rootDir } , ( err , stdout , stderr ) => {
11
+ exec ( " npm run build" , { cwd : rootDir } , ( err , stdout , stderr ) => {
13
12
if ( err ) {
14
13
console . error ( `Error during build: ${ stderr } ` ) ;
15
14
process . exit ( 1 ) ;
@@ -22,17 +21,17 @@ exec('npm run build', { cwd: rootDir }, (err, stdout, stderr) => {
22
21
console . error ( `Error copying file: ${ copyErr . message } ` ) ;
23
22
process . exit ( 1 ) ;
24
23
}
25
- console . log ( `File copied to ${ destFile } ` ) ;
26
24
27
25
// Step 3: Add the file to git
28
- exec ( `git add ${ destFile } ` , { cwd : rootDir } , ( gitErr , gitStdout , gitStderr ) => {
29
- if ( gitErr ) {
30
- console . error ( `Error adding file to git: ${ gitStderr } ` ) ;
31
- process . exit ( 1 ) ;
26
+ exec (
27
+ `git add ${ destFile } ` ,
28
+ { cwd : rootDir } ,
29
+ ( gitErr , gitStdout , gitStderr ) => {
30
+ if ( gitErr ) {
31
+ console . error ( `Error adding file to git: ${ gitStderr } ` ) ;
32
+ process . exit ( 1 ) ;
33
+ }
32
34
}
33
- console . log ( `File added to git: ${ destFile } ` ) ;
34
- } ) ;
35
+ ) ;
35
36
} ) ;
36
37
} ) ;
37
-
38
-
0 commit comments