From 516ec17fa2376a861e4ccc110914b05c66fe89c4 Mon Sep 17 00:00:00 2001 From: Jonas Pommerening Date: Wed, 12 Dec 2012 14:38:53 +0100 Subject: [PATCH] Use jslint node module if present. It's nice that the plugin comes with it's own jslint version, but let's use the jslint node module if it is installed. Use "jslint-core.js" as fallback. --- ftplugin/javascript/jslint/runjslint.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ftplugin/javascript/jslint/runjslint.js b/ftplugin/javascript/jslint/runjslint.js index 9d23cd1..6a74e17 100644 --- a/ftplugin/javascript/jslint/runjslint.js +++ b/ftplugin/javascript/jslint/runjslint.js @@ -4,11 +4,16 @@ var fs, vm, sandbox, jslintCore = 'jslint-core.js'; if (typeof require !== 'undefined') { print = require('util').puts; - fs = require('fs'); - vm = require('vm'); - sandbox = {}; - res = vm.runInNewContext(fs.readFileSync(jslintCore), sandbox, jslintCore); - JSLINT = sandbox.JSLINT; + try { + JSLINT = require('jslint'); + } + catch( ex ) { + fs = require('fs'); + vm = require('vm'); + sandbox = {}; + res = vm.runInNewContext(fs.readFileSync(jslintCore), sandbox, jslintCore); + JSLINT = sandbox.JSLINT; + } } else { load('jslint-core.js'); }