/usr/lib/nodejs/dot/bin/dot-packer is in node-dot 1.1.1-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | #!/usr/bin/env nodejs
/* Continuation of https://github.com/Katahdin/dot-packer */
var program = require('commander'),
dot = require('../');
program
.version('0.0.1')
.usage('dottojs')
.option('-s, --source [value]', 'source folder/file path')
.option('-d, --dest [value]', 'destination folder')
.option('-g, --global [value]', 'the global variable to install the templates in',"window.render")
.option('-p, --package [value]', 'if specified, package all templates from destination folder into specified file')
.parse(process.argv);
if (program.dest) mkdirordie(program.dest);
if (program.package) {
var li = program.package.lastIndexOf('/');
if (li>0) mkdirordie(program.package.substring(0, li));
}
function mkdirordie(path) {
require("mkdirp")(path, function (err) {
if (err) {
console.error(err);
process.exit(1);
}
});
}
var render = dot.process({
path: program.source,
destination: program.dest,
global: program.global
});
if (program.package) {
console.log("Packaging all files into " + program.package);
var fs = require("fs");
var files = [];
var dest = program.dest || './';
if (dest[dest.length-1] !== '/') dest += '/';
var sources = fs.readdirSync(dest);
for(k = 0; k < sources.length; k++) {
name = sources[k];
if (/\.js$/.test(name)) {
files.push(dest + name);
}
}
var result = require("uglify-js").minify(files);
fs.writeFileSync(program.package, result.code);
}
|