Skip to content

Commit 31c4584

Browse files
feat: v0.2.0 [BREAKING CHANGE] (#35)
* fix: -f flag added to npm clean script, prevents failure if ./dist does not exist * feat: v0.1.8 * WIP: added dockerfiles for the remaining langs (#32) * feat: accepting only suported languages * feat: added dockerfiles for the remaining langs * fix: trimming outputs before comparing * fix: error handling got worker.build() * feat: better error handling, closes #18 and #14 * feat: added log for error * feat: v0.1.9 * feat: v0.2.0 [BREAKING CHANGE] (#34) * refactor: [BREAKING CHANGE] changed default import to { CodeExecutor } * docs: [BREAKING CHANGE] default import to { CodeExecutor } * fix: Build only python and bash * docs: worker.build builds all languages by default * feat: v0.2.0 [BREAKING CHANGE] Co-authored-by: Rahil Kabani <[email protected]>
1 parent 5541ca5 commit 31c4584

File tree

10 files changed

+28
-11
lines changed

10 files changed

+28
-11
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,14 @@ You can create a `CodeExecutor` object in the following manner. You must pass th
138138
139139

140140
```js
141-
import CodeExecutor from 'code-executor';
141+
import { CodeExecutor } from 'code-executor';
142+
const codeExecutor = new CodeExecutor('myExecutor', 'redis://127.0.0.1:6379');
143+
```
144+
145+
**OR**
146+
147+
```js
148+
const { CodeExecutor } = require('code-executor');
142149
const codeExecutor = new CodeExecutor('myExecutor', 'redis://127.0.0.1:6379');
143150
```
144151

@@ -182,6 +189,13 @@ import { Worker } from 'code-executor';
182189
const worker = new Worker('myExecutor', 'redis://127.0.0.1:6379');
183190
```
184191

192+
**OR**
193+
194+
```js
195+
const { Worker } = require('code-executor');
196+
const worker = new Worker('myExecutor', 'redis://127.0.0.1:6379');
197+
```
198+
185199
You can create a new `Worker` object and listen with the same `name` and `redis` string you passed to the master class. There is another optional parameter called `options`, which is an object that may consist of the following parameters:
186200

187201
- `folderPath`, _string_: Will be discussed later.
@@ -210,6 +224,8 @@ An object of the `Worker` class has the following important functions:
210224

211225
`worker.build()` is responsible for building docker images on the system. You can pass a list of languages to the function so that it builds images for just the specified languages.
212226

227+
- You can also call `worker.build()` without an argument to build all languages supported by `code-executor`.
228+
213229
```js
214230
async function build() {
215231
await worker.build(['Python', 'Bash']);

examples/master.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import CodeExecutor from '../src/CodeExecutor';
1+
import { CodeExecutor } from '../src';
22
import logger from '../src/utils/logger';
33

44
const codeExecutor = new CodeExecutor('myExecutor', 'redis://127.0.0.1:6379');

examples/worker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Worker } from '../src/CodeExecutor';
1+
import { Worker } from '../src';
22

33
const worker = new Worker('myExecutor', 'redis://127.0.0.1:6379');
44

55
async function main() {
6-
await worker.build();
6+
await worker.build(['Python', 'Bash']);
77

88
worker.start();
99
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "code-executor",
3-
"version": "0.1.9",
3+
"version": "0.2.0",
44
"description": "A CLI/library to execute code against test cases in various languages and obtain relevant results.",
55
"main": "dist/src/CodeExecutor.js",
66
"keywords": [

src/CodeExecutor.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Bull from 'bull';
22
import { v4 as uuid } from 'uuid';
33

4-
import { CodeParams } from './models/models';
4+
import { CodeParams } from './models';
55
import logger from './utils/logger';
66
import { extension } from './utils/findExtension';
77

@@ -32,6 +32,4 @@ export default class CodeExecutor {
3232
}
3333
}
3434

35-
export { default as Worker } from './Worker';
36-
3735
export { languages };

src/Runner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
TestCase,
1010
Result,
1111
Tests,
12-
} from './models/models';
12+
} from './models';
1313
import getOutput from './utils/getOutput';
1414
import saveCode from './utils/saveCode';
1515

src/Worker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Bull from 'bull';
44
import Runner from './Runner';
55
import Builder from './Builder';
66

7-
import { Code, Result, WorkerOptions } from './models/models';
7+
import { Code, Result, WorkerOptions } from './models';
88
import logger from './utils/logger';
99

1010
export default class Worker {

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export { default as CodeExecutor, languages } from './CodeExecutor';
2+
3+
export { default as Worker } from './Worker';
File renamed without changes.

src/utils/saveCode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import writeToFile from './writeToFile';
33
import generateFolder from './generateFolder';
44
import findExtension from './findExtension';
55
import decodeBase64 from './decodeBase64';
6-
import { TestCase } from '../models/models';
6+
import { TestCase } from '../models';
77

88
export default async function saveCode(
99
folderPath: string,

0 commit comments

Comments
 (0)