-
Notifications
You must be signed in to change notification settings - Fork 5
/
_index.js
71 lines (54 loc) · 1.77 KB
/
_index.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
'use strict';
var binding, SASS_OUTPUT_STYLE, SASS_SOURCE_COMMENTS, path;
path = require('path');
try {
binding = require('./build/Release/binding.node');
} catch ( e ) {
throw new Error('build target not found');
}
SASS_OUTPUT_STYLE = {
nested: 0,
expanded: 1,
compact: 2,
compressed: 3
};
SASS_SOURCE_COMMENTS = {
none: 0,
normal: 1,
'default': 1,
map: 2
};
function prepareOptions( options ) {
var paths, style, sourceComments;
options = options || {};
if ( options.file ) {
throw new Error('options.file is not supported!');
}
sourceComments = options.source_comments || options.sourceComments;
if (options.sourceMap && !sourceComments) {
sourceComments = 'map';
}
paths = options.include_paths || options.includePaths || [];
// if (options.sassSyntax) {
// options.is_indented_syntax_src = true;
// // options.data = sass2scss(options.data);
// }
return {
data: options.data,
paths: paths.join(path.delimiter),
imagePath: options.image_path || options.imagePath || '',
style: SASS_OUTPUT_STYLE[options.output_style || options.outputStyle] || 0,
comments: SASS_SOURCE_COMMENTS[sourceComments] || 0,
precision: parseInt(options.precision) || 5,
omit_source_map_url: options.omit_source_map_url ? 1 : 0,
is_indented_syntax_src: options.is_indented_syntax_src || options.sassSyntax ? 1 : 0,
source_map_file: options.source_map_file || ''
};
};
var sass2scss = exports.sass2scss = function(input) {
return binding.sass2scss(input);
}
// 暂只支持options.data用法,因为fis中只会这么用。
exports.renderSync = function( options ) {
return binding.renderSync(prepareOptions(options));
}