-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
executable file
·39 lines (33 loc) · 1.38 KB
/
app.js
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
#!/usr/bin/env node
const path = require('path'),
fs = require('fs'),
vorpal = require('vorpal')(),
readLessFile = require('./lib/read_file'),
lessCompile = require('./lib/compile_less').compile,
createFile = require('./lib/create_file').createFile;
console.log('Please choose a fileName with extension [.less] to compile. Use help command for possible commands.');
vorpal
.delimiter('lcc$')
.show();
vorpal
.command('less [filename] [sourceDir] [cssFileName]', 'Choose directory & filename.less to compile. Detaults to cwd')
.option('-d --default', 'Uses default values [lessMain, ./ , cssMain]')
.action(function(args, cb) {
if (args.filename) {
readAndCompileToCss(args.filename, args.sourceDir, args.cssFileName);
}
if (args.options.default) {
readAndCompileToCss(args.filename, args.sourceDir, args.cssFileName);
}
cb();
})
function readAndCompileToCss(lessFileLess, sourceDir, cssFileName) {
readLessFile(lessFileLess, sourceDir, function (err, dataString) {
if (err) return console.log(err.message);
//console.log(`This is your file content: ${dataString}`);
lessCompile(dataString, function(err, cssData) {
//console.log('this is the css data as string:' + ' ' + cssData.toString());
createFile(cssFileName, cssData);
});//end lessCompile
});//end readLessFile
}//end readAndCompileToCss