From f5464e86fca62231fdf39cb3a2b25e095f7e498e Mon Sep 17 00:00:00 2001 From: Ian Christian Myers Date: Wed, 17 Jul 2013 22:01:48 -0700 Subject: [PATCH] Enabled require("eslint") and exposed out CLI. I've added the "main" key to the package.json, pointing it to lib/api.js. The api.js file exports /lib/eslint.js and /lib/cli.js. This enables those who have run `npm install eslint` to then require eslint in their project like so: var eslint = require("eslint"); Prior to this change calling `require("eslint")` would throw an error. In addition, developers can now use the CLI from their projects, without having to `require` it from the `node_modules` directory (which is generally not good). Developers can now use the CLI programatically, like so: var eslint = require("eslint"); eslint.cli.execute(["-h"]); --- lib/api.js | 9 +++++++++ package.json | 1 + 2 files changed, 10 insertions(+) create mode 100644 lib/api.js diff --git a/lib/api.js b/lib/api.js new file mode 100644 index 00000000000..35be66587a5 --- /dev/null +++ b/lib/api.js @@ -0,0 +1,9 @@ +/** + * @fileoverview Expose out ESLint and CLI to require. + * @author Ian Christian Myers + */ + +module.exports = { + linter: require("./eslint"), + cli: require("./cli") +}; \ No newline at end of file diff --git a/package.json b/package.json index d5da0c5d737..9a5fc39d307 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "bin": { "eslint": "./bin/eslint.js" }, + "main": "./lib/api.js", "scripts": { "changelog": "bash ./scripts/changelog-update.sh", "test": "npm run-script lint && node ./node_modules/istanbul/lib/cli.js cover --print both ./node_modules/vows/bin/vows -- --spec ./tests/*/*.js ./tests/*/*/*.js",