Skip to content
This repository has been archived by the owner on Aug 19, 2019. It is now read-only.

Commit

Permalink
💥 rely on [{ path, data, map }] → support SourceMaps
Browse files Browse the repository at this point in the history
  • Loading branch information
deepsweet committed Feb 11, 2016
1 parent 296f4d2 commit 76dca25
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import start from 'start';
import reporter from 'start-pretty-reporter';
import files from 'start-files';
import clean from 'start-clean';
import read from 'start-read';
import less from 'start-less';
import rename from 'start-rename';
import write from 'start-write';
Expand All @@ -30,14 +31,15 @@ export function build() {
files('build/'),
clean(),
files('lib/**/*.less'),
less(),
read(),
less({ sourceMap: true }),
rename(file => file.replace(/\.less$/, '.css')),
write('build/')
);
}
```

Task is rely on array of files and provides `[{ path, data }]` output, see [documentation](https://github.com/start-runner/start#readme) for details.
Task is rely on `[{ path, data, map }]` input and provide the same, see [documentation](https://github.com/start-runner/start#readme) for details.

## Arguments

Expand Down
25 changes: 10 additions & 15 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,25 @@ const defaultOptions = {

export default (userOptions) => (input) => {
return function less(log) {
const lessTransform = require('less').render;
const pify = require('pify');
const readFile = pify(require('fs').readFile);
const Less = require('less');

return Promise.all(
input.map(file => {
const options = {
...defaultOptions,
...userOptions,
filename: file
filename: file.path
};

return readFile(file, 'utf-8')
.then(data => {
return lessTransform(data, options);
})
.then(result => {
log(file);
return Less.render(file.data, options).then(result => {
log(file.path);

return {
path: file,
data: result.css
};
});
return {
path: file.path,
data: result.css,
map: typeof result.map === 'undefined' ? null : result.map
};
});
})
);
};
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"files": [ "build/" ],
"main": "build/index.js",
"dependencies": {
"pify": "2.x.x",
"less": "2.x.x",
"babel-runtime": "6.x.x"
},
Expand Down

0 comments on commit 76dca25

Please sign in to comment.