Skip to content

Commit 0bdfd05

Browse files
committed
style: update editorconfig and pretierc
1 parent f8deb1b commit 0bdfd05

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ end_of_line = lf
88
indent_style = space
99
insert_final_newline = true
1010
trim_trailing_whitespace = true
11+
max_line_length = 140

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"proseWrap": "never",
33
"singleQuote": true,
44
"trailingComma": "es5",
5-
"printWidth": 130
5+
"printWidth": 140
66
}

src/index.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ class Worker {
3737
this.taskFile = 'null';
3838
this.jobsDone = 0;
3939
this.jobsToDo = []; // push here jobs assigned due working..
40-
this.getBatch = Object.prototype.hasOwnProperty.call(process.env, 'getBatch') ? process.env.getBatch : false
41-
this.batchSize = Object.prototype.hasOwnProperty.call(process.env, 'batchSize') ? process.env.batchSize : 5
40+
this.getBatch = Object.prototype.hasOwnProperty.call(process.env, 'getBatch') ? process.env.getBatch : false;
41+
this.batchSize = Object.prototype.hasOwnProperty.call(process.env, 'batchSize') ? process.env.batchSize : 5;
4242
this.init = this.init.bind(this);
4343
this.onSeen = this.onSeen.bind(this);
4444
this.requestWork = this.requestWork.bind(this);
@@ -114,9 +114,9 @@ class Worker {
114114
if (Helper.getTimestamp() - this.lastRequestWork > minRequestWorkWindow) {
115115
// prevent unnecessary requests , flooding Master
116116
this.lastRequestWork = Helper.getTimestamp(); // track last request for work..
117-
this.peer.rpc(this.MasterAdress, 'requestWork', { getBatch: this.getBatch , batchSize: this.batchSize }, async (masterAns) => {
118-
if (masterAns.task) { // single task
119-
// null if no jobs available
117+
this.peer.rpc(this.MasterAdress, 'requestWork', { getBatch: this.getBatch, batchSize: this.batchSize }, async (masterAns) => {
118+
if (masterAns.task) {
119+
// single task
120120
const job = this.crypt.decrypt(JSON.parse(masterAns.task)); // decrypt once incoming job data
121121
const startedOn = Helper.getTimestamp();
122122
this.doJobs(JSON.parse(job))
@@ -128,11 +128,12 @@ class Worker {
128128
this.log.warn(e.message);
129129
});
130130
}
131-
if (masterAns.batchTasks ){ // received batch tasks
132-
masterAns.batchTasks.forEach((encryptedTask)=>{
131+
if (masterAns.batchTasks) {
132+
// received batch tasks
133+
masterAns.batchTasks.forEach((encryptedTask) => {
133134
const job = this.crypt.decrypt(JSON.parse(encryptedTask));
134-
this.jobsToDo.push(JSON.parse(job)) // push decrypted job to internal queue
135-
})
135+
this.jobsToDo.push(JSON.parse(job)); // push decrypted job to internal queue
136+
});
136137
// this.log.fatal(this.jobsToDo)
137138
this.event.emit('requestWork');
138139
}
@@ -208,7 +209,9 @@ class Worker {
208209
const fileContent = this.crypt.decrypt(asset.content);
209210
const fileDir = path.dirname(`${process.cwd()}${asset.workerPath}`);
210211
fs.mkdirSync(fileDir, { recursive: true }); // create dirs recursively
211-
fs.writeFileSync(`${process.cwd()}${asset.workerPath}`, fileContent, { encoding: 'utf8' });
212+
fs.writeFileSync(`${process.cwd()}${asset.workerPath}`, fileContent, {
213+
encoding: 'utf8',
214+
});
212215
}
213216
}
214217

@@ -297,7 +300,10 @@ class Worker {
297300
if (assetPaths.length > 2) {
298301
// file is inside a dir locally
299302
this.log.warn('Deleting dir ', `${process.cwd()}/${assetPaths[1]}`);
300-
fs.rmSync(`${process.cwd()}/${assetPaths[1]}`, { recursive: true, force: true });
303+
fs.rmSync(`${process.cwd()}/${assetPaths[1]}`, {
304+
recursive: true,
305+
force: true,
306+
});
301307
} else if (assetPaths.length === 2) {
302308
// single file in root of workers dir
303309
this.log.warn('Deleting file ', `${process.cwd()}/${assetPaths[1]}`);

0 commit comments

Comments
 (0)