diff --git a/domain.js b/domain.js index 5d83c82..60816c0 100644 --- a/domain.js +++ b/domain.js @@ -32,13 +32,28 @@ return require((eslintPath || 'eslint') + '/package.json').version; } - try { - cli = getCli(); - currentVersion = getEslintVersion(); - } catch (err) { - logError(err); + function refreshEslintCli(eslintPath, opts) { + try { + currentVersion = getEslintVersion(eslintPath); + // brackets can't work with 3.x right now + if (/^3/.test(currentVersion)) { + var notSupportedVersion = currentVersion; + eslintPath = path.resolve(__dirname, 'node_modules', 'eslint'); + currentVersion = getEslintVersion(eslintPath); + logError( + 'Detected eslint version 3.x (' + notSupportedVersion + + '), falling back to default eslint ' + currentVersion + ); + } + cli = getCli(eslintPath, opts); + } catch (err) { + logError(err); + } + } + refreshEslintCli(); + function uniq(arr) { return arr.reduce(function (result, item) { if (result.indexOf(item) === -1) { @@ -52,7 +67,8 @@ if (dirPath.match(/(\\|\/)$/)) { dirPath = dirPath.slice(0, -1); } - return process.platform === 'win32' ? dirPath.replace(/\//g, '\\') : dirPath; + var dir = process.platform === 'win32' ? dirPath.replace(/\//g, '\\') : dirPath; + return path.resolve(dir, 'node_modules'); } function _setProjectRoot(projectRoot, prevProjectRoot) { @@ -117,13 +133,7 @@ require('module').Module._initPaths(); // console.log('ESLint NODE_PATH', process.env.NODE_PATH); - - try { - cli = getCli(eslintPath, opts); - currentVersion = getEslintVersion(eslintPath); - } catch (err) { - logError(err); - } + refreshEslintCli(eslintPath, opts); } require('enable-global-packages').on('ready', function () { diff --git a/package.json b/package.json index c4c3d3a..7e2b6a7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "brackets-eslint", - "version": "2.5.0", + "version": "2.6.0", "description": "Adds ESLint support to Brackets", "keywords": [ "brackets-extension",