Skip to content

Commit

Permalink
Merge pull request #6 from savetheclocktower/fix-inline-javascript
Browse files Browse the repository at this point in the history
Restore support for inline JavaScript in Less
  • Loading branch information
confused-Techie authored Jul 17, 2023
2 parents 6e01ff3 + 0587958 commit 40bf113
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "less-cache",
"version": "2.0.0",
"version": "2.0.1",
"description": "Less compile cache",
"main": "./src/less-cache",
"scripts": {
Expand Down
8 changes: 8 additions & 0 deletions spec/fixtures/with-js.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.p(@foo) {
@value: ~`@{@foo} + 'px'`;
div {
padding: @value;
}
}

.p(10);
20 changes: 20 additions & 0 deletions spec/less-cache-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,26 @@ describe "LessCache", ->
"""

it "tolerates inline JavaScript", ->
filePath = join(fixturesDir, 'with-js.less')
lessWithJs = """
.p(@foo) {
@value: ~`@{foo} + 'px'`;
div {
padding: @value;
}
}
.p(10);
"""
css = cache.cssForFile(filePath, lessWithJs)
expect(css).toBe """
div {
padding: 10px;
}
"""

describe "::readFileSync(filePath)", ->
[css] = []

Expand Down
7 changes: 6 additions & 1 deletion src/less-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,12 @@ class LessCache {

parseLess(filePath, contents) {
let css = null;
const options = {filename: filePath, syncImport: true, paths: this.importPaths};
const options = {
filename: filePath,
syncImport: true,
paths: this.importPaths,
javascriptEnabled: true
};
// load or assign less and lessFs
if (less === null) {
less = require('less');
Expand Down

0 comments on commit 40bf113

Please sign in to comment.