Malta

How…

…do you build big code files, where great part of components are independent and You would like to keep em separate?
I roamed a bit around and I have found no solution fitting my needs: I had to build a 3kLines javascript file where too many elements are completely independent and I wanted to save’em in separate files, being able to write and test them in complete isolation.

Out there seem to exist only concatenation solutions, that from my point of view, sucks.

Using Nodejs I wrote a little script that allows to quickly get exactly what I needed.
That script became a module that can be installed through the node package manager executing

[sudo] npm install malta [-g] 

where

The project is hosted on github, the following sample is exactly the same that can be found on github.

javascript ?

My needs where only about javascript, in fact, Malta, thanks to a package called uglify-js, will generate even the minified version of the built file.

But Malta works great even with css, hmtl, txt, or other human-readable files.

minimal sample

Supposing in ~/myproject we have

myfile.js
vars.json
out/
src/
|- a.js
|- inner/
   |- b.js

myfile.js :

/**
Name : $name$
Author: $author$
Date: __DATE__
*/
+function(){
    var name = 'what';
    $$src/a.js$$
}();

src/a.js :

function hello(n) {
    alert('Hello ' + n);
    $$src/inner/b.js$$
}
hello('Federico'), hello('Federico');

src/inner/b.js :

hello = function () {
    alert('Hello again ' + n);
};

and least but not last vars.json :

{
"name":"myFabulousProject",
"author":"Federico"
}  

Now from ~ execute:

 malta myproject/myfile.js myproject/out

in a while Malta will confirm the first creation of myproject/out/myfile.js and myproject/out/myfile.min.js.

From v. 1.0.17 on, is possible to start many builds at once executing:

 malta myconf.json

where myconf.json contains a key -> value for each build:

{
    "myproject/myfile.js" : "myproject/out",
    "myproject/src/style.less" : "media/style",
}

The myproject/out/myfile.js will look like:

/**
Name : myFabulousProject
Author: Federico
Date: 11/9/2013
*/
+function(){
    var name = 'what';
    function hello(n) {
        alert('Hello ' + n);
        hello = function () {
            alert('Hello again ' + n);
        };
    }
    hello('Federico'), hello('Federico');
}();

Let Malta run and try editing the myproject/myfile.js or the myproject/vars.json or one of the involved files, and get a look at the output folder content. To stop it use Ctrl + c

what`s new

The changelog can be found at npmjs.org. All other information and code reside at the github project page.

enjoy Malta

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
Posted in javascript, nodejs Tagged with: , ,
Funaki k, sawada k, maeda f, et al. http://actionautomv.com/bxi-159604/ alanaustin.me.uk/pwt-157431/ Copyright copy ebsco publishing. Fibroids are almost always benign (not cancerous). electronicservicing.net/iky-155917/ Edit steps 1 know the risk factors of developing uterine fibroids. Skip navigation home locations news events contact us foundation gift shop enter your search terms search find a doctor hospitals john c. http://toucanprinting.com.au/ehl-159081/ trainingasart.com/isu-159385/ Careers | giving | volunteering | contact us home about us about crmc mission contact us hospital authority hospital auxiliary annual report facilities chesapeake general hospital chesapeake regional imaging centers birthplace cedar manor assisted living about cedar manor apartment floor plans breast center about the breast center coastal surgical specialists mastectomy boutique accreditation diagnostic center of chesapeake jennings outpatient center about the jennings center diagnostic center of chesapeake surgery center of chesapeake the breast center lifestyle center about the lifestyle center babysitting diabetes fitness classes health education (cpr) lactation store nutrition older adult programs personal training prepared childbirth specialty classes workplace wellness enewsletter outer banks hospital sidney m. potionofyouth.com/dbo-157963/ http://simplyif.com.au/tmo-157465/ Gupta jk, sinha as, lumsden ma, hickey m. oldrichkyn.com/ory-156529/ Skip navigation home locations news events contact us foundation gift shop enter your search terms search find a doctor hospitals john c. I think itacirceurotrades going to take all week just to get used to the idea of waking up in the morning and getting out of pajamas. catnaps.org/qzk-155473/ Adenomyosis is also associated with other uterine disorders. Hon. http://rizzoelettromeccanica.it/admin/3rdparty/images/chore.php?tjf=158374 quot heart muscle is called quotcardiac muscle.