Skip to content

Commit

Permalink
Tidy up (#37)
Browse files Browse the repository at this point in the history
* remove gulp-complexity
* remove linting via gulp
* use linting via npm script
* remove gulp completely
* format readme
* remove final var declaration
  • Loading branch information
vernak2539 committed Jul 24, 2019
1 parent 3fc46bf commit a85c7ce
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 2,899 deletions.
1 change: 1 addition & 0 deletions .jshintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./node_modules/**/*
3 changes: 2 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"esversion": 6,
"devel": true,
"browser": false,
"node": true,
Expand All @@ -12,7 +13,7 @@
"newcap": true,
"undef": true,
"shadow": false,
"strict": true,
"strict": false,
"unused": true,
"globals": {
"describe": true,
Expand Down
43 changes: 21 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

## Express LESS Middleware [![Build Status](https://travis-ci.org/vernak2539/express-less-middleware.svg?branch=master)](https://travis-ci.org/vernak2539/express-less-middleware) [![Coverage Status](https://coveralls.io/repos/vernak2539/express-less-middleware/badge.svg?branch=coveralls_support)](https://coveralls.io/r/vernak2539/express-less-middleware?branch=master)

This middleware is designed to compile LESS on the fly.
Expand All @@ -16,12 +15,12 @@ npm install --save express-less-middleware
### What this does (per request)

1. Determines if file requested is: (if conditions aren't met it runs `next()`)
1. requested via GET method
2. a CSS file
1. requested via GET method
2. a CSS file
2. Looks for CSS file requested
* if found it will let it go through the original flow via next
- if found it will let it go through the original flow via next
3. Looks for a LESS file with the same name as the CSS file requested
* if LESS file is found it will read that file and compile it to CSS and deliever the response
- if LESS file is found it will read that file and compile it to CSS and deliever the response
4. If no LESS or CSS file is found, it will give you a 404 like usual

### What this doesn't do
Expand All @@ -31,50 +30,50 @@ npm install --save express-less-middleware
### Setup

**lessMiddleware( options )**
* `options`
* required: no
* default: `./public` (string)
* Type: `String` or `Object`
* `String` - will be path to express public directory.__*__
* `Object` - [less parser options][1]
* `options.publicDir` - same value as if `options` were a string. Same default value
* `options.paths`__*__

- `options`
- required: no
- default: `./public` (string)
- Type: `String` or `Object`
- `String` - will be path to express public directory.__*__
- `Object` - [less parser options][1]
- `options.publicDir` - same value as if `options` were a string. Same default value
- `options.paths`__*__

\* **paths should be relative to cwd.** `path.join` is used with `process.cwd()` as first argument when processing all paths

### Example

```js
var http = require( 'http' );
var express = require( 'express' );
var app = express();
const http = require("http");
const express = require("express");
const app = express();

// this assumes that the publicly available folder is on the same directory level
// as the file that starts your express server
var lessCompiler = require( 'express-less-middleware' )();
const lessCompiler = require("express-less-middleware")();

// if that's not the case, initialize it with the path to your public/client-side folder
// the path should be relative to the directory where the file that starts your express server is
// Example below.
//
// var lessCompiler = require( 'express-less-middleware' );
// const lessCompiler = require( 'express-less-middleware' );
// lessCompiler = lessCompiler( '../path/to/public/folder' );
// OR
// var lessCompiler = require( 'express-less-middleware' );
// const lessCompiler = require( 'express-less-middleware' );
// lessCompiler = lessCompiler({ publicDir: '../path/to/public/folder', ... });

// ....everything else that has to do with configuring

// you should only use this when developing. Not meant for production
if( process.env.NODE_ENV === 'dev' ) {
if (process.env.NODE_ENV === "dev") {
// this must be "used" before express.use( express.static() ) or it will not work (no next())
app.use( lessCompiler );
app.use(lessCompiler);
}

// ....other stuff relative to your express app

http.createServer( app ).listen( 8000 );
http.createServer(app).listen(8000);
```

#### License
Expand Down
43 changes: 0 additions & 43 deletions gulpfile.js

This file was deleted.

10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,16 @@
"through2": "~3.0.0"
},
"scripts": {
"lint": "jshint ./**/*.js --config ./.jshintrc",
"test": "yarn lint && yarn test:coverage",
"test:local": "mocha --reporter=spec --watch",
"test": "istanbul cover _mocha --report lcovonly -- test/spec.js --reporter list --timeout 100000 && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"
"test:coverage": "istanbul cover _mocha --report lcovonly -- test/spec.js --reporter list --timeout 100000 && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"
},
"devDependencies": {
"coveralls": "~3.0.1",
"express": "~4.17.0",
"gulp": "~4.0.2",
"gulp-complexity": "~0.3.0",
"gulp-jshint": "~2.1.0",
"gulp-mocha": "~6.0.0",
"istanbul": "~0.4.5",
"jshint-stylish": "~2.2.1",
"jshint": "^2.10.2",
"mocha": "~6.2.0",
"mocha-lcov-reporter": "~1.3.0",
"supertest": "~4.0.0"
Expand Down
Loading

0 comments on commit a85c7ce

Please sign in to comment.