Skip to content

Commit

Permalink
Correct source maps checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Amphiluke committed Jun 18, 2019
1 parent 22afe99 commit ccb3fa5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ The supported options are:

### `getRoots(options)`

This methods just returns a Promise that resolves with a list of the root file paths. It accepts the same options as the [`compileRoots`](#compileroots-options) method except the `lessOptions` parameter. This method may be useful if you just need to get the list of root Less files without compiling them.
This methods just returns a Promise that resolves with a list of the root file paths. It accepts the same options as the [`compileRoots`](#compilerootsoptions) method except the `lessOptions` parameter. This method may be useful if you just need to get the list of root Less files without compiling them.

## Requirements

Expand Down
5 changes: 3 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ async function getImports(entries) {

function compile(entries, lessOptions) {
let less = require("less");
let inlineMap = lessOptions.sourceMap && lessOptions.sourceMap.sourceMapFileInline;
let promises = entries.map(entry =>
readFile(entry)
.then(data => less.render(data, {
Expand All @@ -69,10 +70,10 @@ function compile(entries, lessOptions) {
}))
.then(({css, map}) => {
let writeCSS = writeFile(setExt(entry, ".css"), css);
if (!map) {
if (!map || inlineMap) {
return writeCSS;
}
let writeMap = writeFile(setExt(entry, ".map"), map);
let writeMap = writeFile(setExt(entry, ".css.map"), map);
return Promise.all([writeCSS, writeMap]);
})
);
Expand Down
5 changes: 3 additions & 2 deletions src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ async function getImports(entries) {

function compile(entries, lessOptions) {
let less = require("less");
let inlineMap = lessOptions.sourceMap && lessOptions.sourceMap.sourceMapFileInline;
let promises = entries.map(entry =>
readFile(entry)
.then(data => less.render(data, {
Expand All @@ -37,10 +38,10 @@ function compile(entries, lessOptions) {
}))
.then(({css, map}) => {
let writeCSS = writeFile(setExt(entry, ".css"), css);
if (!map) {
if (!map || inlineMap) {
return writeCSS;
}
let writeMap = writeFile(setExt(entry, ".map"), map);
let writeMap = writeFile(setExt(entry, ".css.map"), map);
return Promise.all([writeCSS, writeMap]);
})
);
Expand Down

0 comments on commit ccb3fa5

Please sign in to comment.