1 | let fs = require('fs')
|
2 | let _ = require('lodash')
|
3 | let dir = __dirname + '/replacements/'
|
4 | let sassToLess = function() {}
|
5 |
|
6 | let replacements = function () {
|
7 | let filenames = fs.readdirSync(dir)
|
8 |
|
9 | let results = filenames.map(function (filename) {
|
10 | return require(dir + filename)
|
11 | })
|
12 |
|
13 | return _.sortBy(results, 'order')
|
14 | }
|
15 |
|
16 | sassToLess.prototype = {
|
17 | process: function(src, extra) {
|
18 |
|
19 | if (extra.fileInfo && !/\.s[a|c]ss/i.test(extra.fileInfo.filename)) {
|
20 | return src
|
21 | }
|
22 |
|
23 |
|
24 | return [src].concat(replacements()).reduce(function(source, item) {
|
25 | return source.replace(item.pattern, item.replacement)
|
26 | })
|
27 | }
|
28 | }
|
29 |
|
30 | module.exports = sassToLess
|