Skip to content

Commit

Permalink
Extract core_d
Browse files Browse the repository at this point in the history
  • Loading branch information
mantoni committed Feb 26, 2019
1 parent 48a95f5 commit 786d439
Show file tree
Hide file tree
Showing 16 changed files with 56 additions and 1,320 deletions.
12 changes: 8 additions & 4 deletions bin/eslint_d.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ if (cmd === '-h' || cmd === '--help') {
return;
}

const client = require('../lib/client');
process.env.CORE_D_TITLE = 'eslint_d';
process.env.CORE_D_DOTFILE = '.eslint_d';
process.env.CORE_D_SERVICE = require.resolve('../lib/linter');

const core_d = require('core_d');

if (cmd === 'start'
|| cmd === 'stop'
|| cmd === 'restart'
|| cmd === 'status') {
client[cmd]();
core_d[cmd]();
return;
}

Expand All @@ -34,9 +38,9 @@ if (args.indexOf('--stdin') > -1) {
text += chunk;
});
process.stdin.on('end', () => {
client.lint(args, text);
core_d.invoke(args, text);
});
return;
}

client.lint(args);
core_d.invoke(args);
103 changes: 0 additions & 103 deletions lib/client.js

This file was deleted.

27 changes: 0 additions & 27 deletions lib/connect.js

This file was deleted.

18 changes: 0 additions & 18 deletions lib/daemon.js

This file was deleted.

61 changes: 0 additions & 61 deletions lib/launcher.js

This file was deleted.

14 changes: 10 additions & 4 deletions lib/linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ function clearRequireCache(cwd) {
});
}

exports.lint = function (cwd, args, text, mtime) {
/*
* The core_d service entry point.
*/
exports.invoke = function (cwd, args, text, mtime) {
process.chdir(cwd);

let cache = eslintCache.get(cwd);
Expand Down Expand Up @@ -129,13 +132,16 @@ exports.lint = function (cwd, args, text, mtime) {

exports.cache = eslintCache;

/*
* The core_d status hook.
*/
exports.getStatus = function () {
const { keys } = eslintCache;
if (keys.length === 0) {
return 'Running, no instances cached';
return 'No instances cached.';
}
if (keys.length === 1) {
return 'Running, one instance cached';
return 'One instance cached.';
}
return `Running, ${keys.length} instances cached`;
return `${keys.length} instances cached.`;
};
5 changes: 0 additions & 5 deletions lib/out.js

This file was deleted.

31 changes: 0 additions & 31 deletions lib/portfile.js

This file was deleted.

Loading

0 comments on commit 786d439

Please sign in to comment.