/** * @author Robert Strutts * @copyright Copyright (c) 2022, Robert Strutts. * @license MIT */ const { src, dest, series, parallel, watch } = require('gulp'); const exec = require('child_process').exec; const args = process.argv.slice(2); // Ignore node/path var all_args = ""; for(let i = 0; i < args.length; i++) { all_args += " " + args[i]; } const php_source_files = [ '**/*.php', '!**/dist/*.php' ]; function compile_php_files() { return new Promise(function(resolve, reject) { exec('php -f compiler.php -- ' + all_args, function (err, stdout, stderr) { console.log(stdout); console.log(stderr); resolve(stdout); }); }); } async function help() { console.log(`compiler options: --prod [will minify all files] --dev [combines files UN-minified] --authors [Removes all comments including authors] `); } function watch_php() { process.chdir('src'); watch(php_source_files, compile_php_files); } exports.default = series(watch_php); exports.help = help;