Skip to content

Commit

Permalink
update build.php & favor npm over yarn
Browse files Browse the repository at this point in the history
  • Loading branch information
nRamstedt committed Sep 6, 2023
1 parent dd72957 commit db4780d
Show file tree
Hide file tree
Showing 3 changed files with 33,448 additions and 10,300 deletions.
27 changes: 16 additions & 11 deletions build.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,32 @@
$buildCommands = [];

//Add composer build, if flag --no-composer is undefined.
//Dump autloader.
//Dump autloader.
//Only if composer.json exists.
if(file_exists('composer.json')) {
if(is_array($argv) && !in_array('--no-composer', $argv)) {
$buildCommands[] = 'composer install --prefer-dist --no-progress --no-dev';
if (file_exists('composer.json')) {
if (is_array($argv) && !in_array('--no-composer', $argv)) {
$buildCommands[] = 'composer install --prefer-dist --no-progress --no-dev';
}
$buildCommands[] = 'composer dump-autoload';
}

//Run npm if package.json is found
if(file_exists('package.json') && file_exists('package-lock.json')) {
if (file_exists('package.json') && file_exists('package-lock.json')) {
$buildCommands[] = 'npm ci --no-progress --no-audit';
} elseif(file_exists('package.json') && !file_exists('package-lock.json')) {
} elseif (file_exists('package.json') && !file_exists('package-lock.json')) {
$buildCommands[] = 'npm install --no-progress --no-audit';
}

//Run build if package-lock.json is found
if(file_exists('package-lock.json') && !file_exists('gulp.js')) {
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)) {
} elseif (
file_exists('package-lock.json') &&
file_exists('gulp.js') &&
is_array($argv) &&
in_array('--allow-gulp', $argv)
) {
$buildCommands[] = 'gulp';
}

Expand All @@ -61,7 +66,7 @@
'./source/js/',
'LICENSE',
'babel.config.js',
'yarn.lock'
'yarn.lock',
];

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

// Remove files and directories if '--cleanup' argument is supplied to save local developers from disasters.
if(is_array($argv) && in_array('--cleanup', $argv)) {
if (is_array($argv) && in_array('--cleanup', $argv)) {
foreach ($removables as $removable) {
if (file_exists($removable)) {
print "Removing $removable from $dirName\n";
Expand All @@ -106,7 +111,7 @@ function executeCommand($command)

$proc = popen($fullCommand, 'r');

$liveOutput = '';
$liveOutput = '';
$completeOutput = '';

while (!feof($proc)) {
Expand Down
Loading

0 comments on commit db4780d

Please sign in to comment.