A simple builder for your modules or scripts.

Tweiii

Mouse
If you would like to use separate files for obvious reasons or not too much.
Code:
JavaScript:
const luamin = require('luamin');
const fs = require('fs');
exports.build = function(output, folder, files) {
    var callback = 0;
    if(fs.existsSync(`./${output}`)) {
        fs.unlinkSync(`./${output}`);
    }
    files.forEach((name) => {
        if(fs.existsSync(`./${folder}/${name}`)) {
            callback++;
            if(callback == files.length) {
                let lua = fs.readFileSync(`./${folder}/${name}`);
                fs.appendFileSync(`./${output}`, `${lua}\n`);
                console.log(`Processed file ${name}`);
                console.log('Done, now parsing.');
                return finish(output);
            }
            let lua = fs.readFileSync(`./${folder}/${name}`);
            fs.appendFileSync(`./${output}`, `${lua}\n`);
            console.log(`Processed file ${name}`);
        }
    });
}
const finish = function(output) {
    let lua = fs.readFileSync(`./${output}`);
    let minifed = luamin.minify(lua.toString());
    fs.writeFileSync(`./${output}`, minifed, {encoding: 'utf8', flag: 'w'});
    return console.log('Finished and done parsing.');
}
Before usage you must download Node.js and then, in command prompt (or cmd/terminal) run
Code:
npm install -g luamin
.
After that save the code I gave you, in your command prompt (or cmd/terminal) execute the command
Code:
node
then execute
JavaScript:
require('./thefileyousaveditas.js').build('output.lua', 'src', ['1.lua', '2.lua', '3.lua']);
REMINDER: You edit thefileyousaveditas to what you saved the code as .
Now for a simple explanation:
The first argument
Code:
output.lua
is the file that will be outputted when it's done.
The second argument
Code:
src
would be the folder all lua files are in.
The third argument
Code:
['1.lua', '2.lua', '3.lua']
would be a array of files that you want appended, make sure this is in CORRECT ORDER of with the files your combining.
last reminder: The output.lua file gets compressed so if there's a error, don't edit that file, edit the separate files included.
 
Last edited:
Top
"Dev-TR" theme by Soulzone