Skip to content

feat: v0.2.0 [BREAKING CHANGE] #35

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

Merged
merged 9 commits into from
Oct 1, 2020
Merged
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
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