Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #17 from aminya/less3
Browse files Browse the repository at this point in the history
Less 3
  • Loading branch information
sadick254 authored Dec 11, 2020
2 parents 58765c1 + 9f85e26 commit ea484ed
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 55 deletions.
38 changes: 0 additions & 38 deletions Gruntfile.coffee

This file was deleted.

31 changes: 16 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
"description": "Less compile cache",
"main": "./lib/less-cache",
"scripts": {
"prepublish": "grunt clean lint coffee",
"test": "grunt test"
"clean": "shx rm -rf lib",
"test": "jasmine-focused --captureExceptions --coffee spec",
"coffee": "npm run clean && shx cp -r src lib && coffee -c -M -o lib lib && shx rm -rf lib/*.coffee",
"build": "npm run coffee",
"prepare": "npm run build"
},
"repository": {
"type": "git",
Expand All @@ -27,20 +30,18 @@
}
],
"dependencies": {
"fs-plus": "^3.0.0",
"less": "^2.7.1",
"underscore-plus": "1.x",
"walkdir": "0.0.11"
"fs-plus": "^3.1.1",
"less": "^3.12.2",
"underscore-plus": "^1.7.0",
"walkdir": "^0.4.1"
},
"devDependencies": {
"fstream": "^1.0.10",
"grunt": "^1.0.1",
"grunt-cli": "^1.2.0",
"grunt-coffeelint": "0.0.16",
"grunt-contrib-coffee": "^1.0.0",
"grunt-shell": "^1.3.0",
"jasmine-focused": "1.x",
"temp": "^0.8.3",
"tmp": "0.0.28"
"coffeescript": "^1.12.7",
"fstream": "^1.0.12",
"jasmine-focused": "^1",
"temp": "^0.9.4",
"tmp": "0.2.1",
"shx": "^0.3.3",
"cross-env": "^7.0.3"
}
}
14 changes: 12 additions & 2 deletions src/less-cache.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ class LessCache

observeImportedFilePaths: (callback) ->
importedPaths = []
lessFs ?= require 'less/lib/less-node/fs.js'
# load or assign less and lessFs
if (less == null)
less = require 'less'
lessFs = less.fs
else if (lessFs == null)
lessFs = less.fs
originalFsReadFileSync = lessFs.readFileSync
lessFs.readFileSync = (filePath, args...) =>
relativeFilePath = @relativize(@resourcePath, filePath) if @resourcePath
Expand Down Expand Up @@ -196,7 +201,12 @@ class LessCache
parseLess: (filePath, contents) ->
css = null
options = filename: filePath, syncImport: true, paths: @importPaths
less ?= require('less')
# load or assign less and lessFs
if (less == null)
less = require 'less'
lessFs = less.fs
else if (lessFs == null)
lessFs = less.fs
imports = @observeImportedFilePaths ->
less.render contents, options, (error, result) ->
if error?
Expand Down

0 comments on commit ea484ed

Please sign in to comment.