HEX
Server: Apache
System: Linux ecngx285.inmotionhosting.com 4.18.0-553.79.1.lve.el8.x86_64 #1 SMP Wed Oct 15 17:59:35 UTC 2025 x86_64
User: zeusxp5 (3862)
PHP: 8.3.28
Disabled: NONE
Upload Files
File: /home/zeusxp5/chuair.org/wp-content/themes/lifttruck/zip-theme.js
const path = require('path');
const zipdir = require('zip-dir');
const fs = require('fs-extra');

const themeFolder = path.resolve(__dirname);
const themeName = path.basename(themeFolder);
const outputZip = path.resolve(path.join(__dirname, '..'), `${themeName}.zip`);
const zipDir = path.join(path.join(__dirname, '..'), 'temp');
const tempDir = path.join(path.join(__dirname, '..'), 'temp', themeName);

// Create a temporary directory and copy the contents of the theme folder
fs.emptyDirSync(tempDir);
const copyOptions = {
  filter: (src, dest) => {
    // Exclude the node_modules directory from the copy
    return !src.includes('node_modules');
  },
};

fs.copySync(themeFolder, tempDir, copyOptions);

const options = {
  saveTo: outputZip,
  filter: (path, stat) => {
    if (path.includes('node_modules') ||
        path.includes('resources') ||
        path.includes('src') ||
        path.includes('package') ||
        path.includes('webpack.config') ||
        path.includes('zip-theme')) {
      return false;
    }

    const fileName = path.split('\\').pop();
    if (/^\..*/.test(fileName)) {
      return false;
    }
    return true;
  },
  //each: (path) => console.log(`${path} added!`),
};

// Zip the contents of the temporary directory
zipdir(zipDir, options, function (err, buffer) {
  if (err) {
    console.error(err);
  } else {
    console.log(`${buffer.length} total bytes`);
    console.log('ZIP file created successfully!');
  }

  // Remove the temporary directory
  fs.removeSync(zipDir);
});