]> git.wh0rd.org - tt-rss.git/blame - lib/dijit/themes/claro/compile.js
lib: Upgrade Dojo and Dijit from 1.8.3 to 1.12.1
[tt-rss.git] / lib / dijit / themes / claro / compile.js
CommitLineData
81bea17a
AD
1// Script to process all the less files and convert them to CSS files
2// Run from themes/dijit/claro like:
3//
4// $ node compile.js
5
81bea17a
AD
6var fs = require('fs'), // file system access
7 path = require('path'), // get directory from file name
6887a0f5 8 less = require('../../../util/less/lib/less'); // less processor
81bea17a
AD
9
10var options = {
11 compress: false,
12 optimization: 1,
13 silent: false
14};
15
16var allFiles = [].concat(
17 fs.readdirSync("."),
18 fs.readdirSync("form").map(function(fname){ return "form/"+fname; }),
19 fs.readdirSync("layout").map(function(fname){ return "layout/"+fname; })
20 ),
21 lessFiles = allFiles.filter(function(name){ return name && name != "variables.less" && /\.less$/.test(name); });
22
23lessFiles.forEach(function(fname){
24 console.log("=== " + fname);
1354d172 25 fs.readFile(fname, 'utf-8', function(e, data){
81bea17a
AD
26 if(e){
27 console.error("lessc: " + e.message);
28 process.exit(1);
29 }
30
31 new(less.Parser)({
32 paths: [path.dirname(fname)],
33 optimization: options.optimization,
34 filename: fname
35 }).parse(data, function(err, tree){
36 if(err){
37 less.writeError(err, options);
38 process.exit(1);
39 }else{
40 try{
41 var css = tree.toCSS({ compress: options.compress }),
42 outputFname = fname.replace('.less', '.css');
1354d172 43 var fd = fs.openSync(outputFname, "w");
81bea17a
AD
44 fs.writeSync(fd, css, 0, "utf8");
45 }catch(e){
46 less.writeError(e, options);
47 process.exit(2);
48 }
49 }
50 });
51 });
52});