Skip to content

Commit

Permalink
Added new main entry file for Node. This package is not meant to be u…
Browse files Browse the repository at this point in the history
…sed as a node module but will now present a more meaningful error. If the project has been built then it will require the build file. This resolves #208
  • Loading branch information
ironikart committed May 14, 2018
1 parent a52049f commit da3f24e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package-lock.json

# Build files #
###############
build/
node_modules/
Auditor/Auditor_with_beacon.js

# OS generated files #
######################
Expand Down
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var fs = require('fs');
var scriptPath = __dirname+'/build/HTMLCS.js';

if (fs.existsSync(scriptPath) === true) {
module.exports = require(scriptPath);
} else {
throw new Error('HTMLCS must be built using `grunt build` before it can be required in Nodejs.');
}
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "html_codesniffer",
"version": "2.1.1",
"description": "HTML_CodeSniffer is a client-side JavaScript that checks a HTML document or source code, and detects violations of a defined coding standard.",
"main": "HTMLCS.js",
"main": "index.js",
"keywords": [
"htmlcs"
],
Expand All @@ -20,10 +20,12 @@
"homepage": "http://squizlabs.github.io/HTML_CodeSniffer/",
"dependencies": {
"grunt": "^1.0.0",
"load-grunt-tasks": "~3.5.x",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-jshint": "^1.0.0",
"grunt-contrib-uglify": "^2.0.0",
"grunt-contrib-watch": "^1.0.0"
"grunt-contrib-watch": "^1.0.0",
"load-grunt-tasks": "^3.5.2"
},
"devDependencies": {
"grunt-contrib-uglify": "^2.3.0"
}
}
}

0 comments on commit da3f24e

Please sign in to comment.