SoFunction
Updated on 2025-04-05

A simple project packaging tool written in nodejs


//General module
var Util = require('util'),
    FS = require('fs'),
    getDeps = require('./getDeps'),
    Uglify = require('./uglify/uglify-js'),
    removeBOMChar = require('./removeBOM').removeBOMChar,
    PATH =require('path');

var packagedObj = {};//Is it already packaged

= function(filePath, rootPath, opts){
    opts = opts || {};

    var str = jscombo(filePath,rootPath);
    if(){
        return str;
    }else{
        return Uglify(str);  
    }
};

function jscombo(filePaths, rootPath){
    if((filePaths)){
        return (function(filePath){           
            filePath = (rootPath,filePath);

//Pack once only
            if(packagedObj[filePath]){
                return '';
            }
            packagedObj[filePath] = 1;

//Is it exists
            if((filePath)){
//Asynchronously read content
                var str = (filePath, 'utf-8');
//Remove the BOM header
                str = removeBOMChar(str);
                var result = getDeps(str, rootPath);
                var content = ;
                content = '//'+filePath+'\n'+content;

//Recursively packaged
                if(){
                    return jscombo(, rootPath) + content;
                }               
//Return to content
                return content;
            }else{
//The file does not have an error message
                ('jsCombo Error: ' + filePath + ' does not exsist! the path is:'+rootPath);
                return ';alert("' + filePath + ' does not exsist!");';
            }           
        }).join(';\n');

    }else{
        return jscombo([filePaths],rootPath);
    }
}