-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcli.js
More file actions
61 lines (50 loc) · 1.56 KB
/
cli.js
File metadata and controls
61 lines (50 loc) · 1.56 KB
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
53
54
55
56
57
58
59
60
61
#!/usr/bin/env node
'use strict';
var Promise = require('bluebird'),
flatten = require('array-flatten'),
yargs = require('yargs'),
sassIncludePaths = require('./'),
sasscIncludeArgs = require('./lib/sassc-include-args');
var argv = yargs
.alias('v', 'version')
.version(function() { return require('./package').version; })
.boolean('node_modules')
.boolean('bower_components')
.boolean('ruby-gems-bundle')
.boolean('ruby-gems-system')
.boolean('sassc')
.argv;
if(!argv['node_modules'] &&
!argv['bower_components'] &&
!argv['ruby-gems-bundle'] &&
!argv['ruby-gems-system']) {
console.error('Warning: No include path sources selected by user.');
console.error('--sassc, --node_modules, --bower_components, --ruby-gems-bundle, --ruby-gems-system');
}
var getIncludePaths = [];
if(argv['node_modules']) {
getIncludePaths.push(sassIncludePaths.nodeModules());
}
if(argv['bower_components']) {
getIncludePaths.push(sassIncludePaths.bowerComponents());
}
if(argv['ruby-gems-bundle']) {
getIncludePaths.push(sassIncludePaths.rubyGemsBundle());
}
if(argv['ruby-gems-system']) {
getIncludePaths.push(sassIncludePaths.rubyGemsSystem());
}
Promise.all(getIncludePaths)
.then(function(gotIncludePaths) {
return flatten(gotIncludePaths);
})
.then(function(includePaths) {
if(includePaths.length == 0) {
console.error('Warning: No include paths were found/passed!');
}
if(argv.sassc) {
console.log(sasscIncludeArgs(includePaths));
return;
}
console.log(includePaths);
});