Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Commit a25dfbd

Browse files
author
steelbrain
committed
🆕 Add getCliFromPath helper
1 parent 4b092fa commit a25dfbd

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/helpers.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
'use babel'
22

3+
import Path from 'path'
4+
import FS from 'fs'
35
import ChildProcess from 'child_process'
46
import CP from 'childprocess-promise'
57

8+
export const bundledEslintPath = Path.join(FS.realpathSync(Path.join(__dirname, '..')), 'node_modules', 'eslint')
9+
610
export function spawnWorker() {
711
let shouldLive = true
812
const env = Object.create(process.env)
@@ -34,3 +38,13 @@ export function spawnWorker() {
3438
process.removeListener('exit', killer)
3539
}}}
3640
}
41+
42+
export function getCliFromPath(path) {
43+
try {
44+
return require(Path.join(path, 'lib', 'cli.js'))
45+
} catch (e) {
46+
if (e.code === 'MODULE_NOT_FOUND') {
47+
throw new Error('ESLint not found, Please install or make sure Atom is getting $PATH correctly')
48+
} else throw e
49+
}
50+
}

0 commit comments

Comments
 (0)