Skip to content

Commit

Permalink
Update build.php
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Thulin committed Sep 1, 2023
1 parent ab1ee1c commit 44f7049
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions build.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
exit(0);
}

/* Parameters:
--no-composer Does not install vendors. Just create the autoloader.
--cleanup Remove removeables.
--allow-gulp Allow gulp to be used.
*/

// Any command needed to run and build plugin assets when newly cheched out of repo.
$buildCommands = [];

Expand All @@ -17,7 +23,7 @@
}
$buildCommands[] = 'composer dump-autoload';
}
/*

//Run npm if package.json is found
if(file_exists('package.json') && file_exists('package-lock.json')) {
$buildCommands[] = 'npm ci --no-progress --no-audit';
Expand All @@ -26,16 +32,19 @@
}

//Run build if package-lock.json is found
if(file_exists('package-lock.json')) {
if(file_exists('package-lock.json') && !file_exists('gulp.js')) {
$buildCommands[] = 'npx --yes browserslist@latest --update-db';
$buildCommands[] = 'npm run build';
}*/
} elseif(file_exists('package-lock.json') && file_exists('gulp.js') && is_array($argv) && in_array('--allow-gulp', $argv)) {
$buildCommands[] = 'gulp';
}

// Files and directories not suitable for prod to be removed.
$removables = [
'.git',
'.gitignore',
'.github',
'.gitattributes',
'build.php',
'.npmrc',
'composer.json',
Expand All @@ -45,7 +54,14 @@
'package-lock.json',
'package.json',
'phpunit.xml.dist',
'README.md'
'README.md',
'gulpfile.js',
'./node_modules/',
'./source/sass/',
'./source/js/',
'LICENSE',
'babel.config.js',
'yarn.lock'
];

$dirName = basename(dirname(__FILE__));
Expand All @@ -65,7 +81,7 @@
}

// Remove files and directories if '--cleanup' argument is supplied to save local developers from disasters.
if (isset($argv[1]) && $argv[1] === '--cleanup') {
if(is_array($argv) && in_array('--cleanup', $argv)) {
foreach ($removables as $removable) {
if (file_exists($removable)) {
print "Removing $removable from $dirName\n";
Expand Down

0 comments on commit 44f7049

Please sign in to comment.