Skip to content

chore: convert the worker.js file into multiple smaller files #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
64 changes: 37 additions & 27 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,32 @@
"atom": "readonly"
},
"parserOptions": {
"ecmaVersion": "latest",
"ecmaVersion": "2020",
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
"jsx": false
}
},
"plugins": [
"import"
"import",
"n"
],
"extends": [
"eslint:recommended"
"eslint:recommended",
"plugin:n/recommended"
],
"root": true,
"rules": {
"no-trailing-spaces": [
"error",
{ "ignoreComments": true }
],
"no-trailing-spaces": [ "error", { "ignoreComments": true } ],
"no-console": "off",
"max-len": [
1,
{
"code": 130
}
],
"semi": [
"error",
"always"
],
"comma-dangle": "off",
"max-len": [ 1, { "code": 130 } ],
"semi": [ "error", "always" ],
// "comma-dangle": ["error", "never"],
// "quotes": ["error", "double"],
"global-require": "off",
"import/no-import-module-exports": "off",
"import/no-unresolved": [
"error",
{
"ignore": [
"atom"
]
}
],
"import/no-unresolved": [ "error", { "ignore": [ "atom" ] } ],
"n/no-missing-import": 'off',
"object-curly-newline": [
"error",
{
Expand All @@ -64,4 +50,28 @@
}
]
},

"settings": {
"node": {
# The Pulsar node version
"version": "^14.16.0",
},
},

"overrides": [
{
"files": [ "./lib/worker/*.js" ],

"parserOptions": {
"ecmaVersion": "2019",
"sourceType": "commonjs"
},
"settings": {
"node": {
# The ESLint minimum supported node version
"version": "^12.22.0",
},
}
}
]
}
6 changes: 4 additions & 2 deletions lib/job-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class JobManager {
constructor () {
this.handlersForJobs = new Map();
this.worker = null;
this.workerPath = Path.join(__dirname, 'worker.js');
this.workerPath = Path.join(__dirname, 'worker/worker.js');
}

dispose () {
Expand Down Expand Up @@ -168,7 +168,9 @@ class JobManager {
}

killWorker (worker) {
worker ??= this.worker;
if (worker == null) {
worker = this.worker;
}
if (!worker || worker.exitCode) { return; }
worker.removeAllListeners();
worker.kill();
Expand Down
2 changes: 1 addition & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default {

async activate () {
Config.initialize();
this.workerPath = Path.join(__dirname, 'worker.js');
this.workerPath = Path.join(__dirname, 'worker/worker.js');
this.jobManager = new JobManager();

// “Inactive” is the mode we enter when we think a project won’t be doing
Expand Down
11 changes: 10 additions & 1 deletion lib/node-path-tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@ const NodePathTester = {
return this._knownGoodValues.get(bin);
}
try {
let stdout = execSync(`${bin} --version`);
let stdout = execSync(
`${bin} --version`,
{
stdio: [
'ignore', // Ignore stdin
undefined, // return stdout
'ignore' // Ignore stderr
]
}
);
this._knownGoodValues.set(bin, stdout);
return stdout;
} catch (err) {
Expand Down
Loading