Skip to content

Commit

Permalink
feat: v0.2.0 [BREAKING CHANGE] (#35)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
roerohan and alias-rahil authored Oct 1, 2020
1 parent 5541ca5 commit 31c4584
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 11 deletions.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,14 @@ You can create a `CodeExecutor` object in the following manner. You must pass th

```js
import CodeExecutor from 'code-executor';
import { CodeExecutor } from 'code-executor';
const codeExecutor = new CodeExecutor('myExecutor', 'redis://127.0.0.1:6379');
```

**OR**

```js
const { CodeExecutor } = require('code-executor');
const codeExecutor = new CodeExecutor('myExecutor', 'redis://127.0.0.1:6379');
```

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

**OR**

```js
const { Worker } = require('code-executor');
const worker = new Worker('myExecutor', 'redis://127.0.0.1:6379');
```

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:

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

`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.

- You can also call `worker.build()` without an argument to build all languages supported by `code-executor`.

```js
async function build() {
await worker.build(['Python', 'Bash']);
Expand Down
2 changes: 1 addition & 1 deletion examples/master.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import CodeExecutor from '../src/CodeExecutor';
import { CodeExecutor } from '../src';
import logger from '../src/utils/logger';

const codeExecutor = new CodeExecutor('myExecutor', 'redis://127.0.0.1:6379');
Expand Down
4 changes: 2 additions & 2 deletions examples/worker.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Worker } from '../src/CodeExecutor';
import { Worker } from '../src';

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

async function main() {
await worker.build();
await worker.build(['Python', 'Bash']);

worker.start();
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "code-executor",
"version": "0.1.9",
"version": "0.2.0",
"description": "A CLI/library to execute code against test cases in various languages and obtain relevant results.",
"main": "dist/src/CodeExecutor.js",
"keywords": [
Expand Down
4 changes: 1 addition & 3 deletions src/CodeExecutor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Bull from 'bull';
import { v4 as uuid } from 'uuid';

import { CodeParams } from './models/models';
import { CodeParams } from './models';
import logger from './utils/logger';
import { extension } from './utils/findExtension';

Expand Down Expand Up @@ -32,6 +32,4 @@ export default class CodeExecutor {
}
}

export { default as Worker } from './Worker';

export { languages };
2 changes: 1 addition & 1 deletion src/Runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
TestCase,
Result,
Tests,
} from './models/models';
} from './models';
import getOutput from './utils/getOutput';
import saveCode from './utils/saveCode';

Expand Down
2 changes: 1 addition & 1 deletion src/Worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Bull from 'bull';
import Runner from './Runner';
import Builder from './Builder';

import { Code, Result, WorkerOptions } from './models/models';
import { Code, Result, WorkerOptions } from './models';
import logger from './utils/logger';

export default class Worker {
Expand Down
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { default as CodeExecutor, languages } from './CodeExecutor';

export { default as Worker } from './Worker';
File renamed without changes.
2 changes: 1 addition & 1 deletion src/utils/saveCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import writeToFile from './writeToFile';
import generateFolder from './generateFolder';
import findExtension from './findExtension';
import decodeBase64 from './decodeBase64';
import { TestCase } from '../models/models';
import { TestCase } from '../models';

export default async function saveCode(
folderPath: string,
Expand Down

0 comments on commit 31c4584

Please sign in to comment.