diff --git a/src/Job/Job.ts b/src/Job/Job.ts index dca15a25..5e5471b0 100644 --- a/src/Job/Job.ts +++ b/src/Job/Job.ts @@ -21,7 +21,7 @@ export type JobCallback = { }; export interface Job { - jobType: Job.Type; + jobType: JobType; name: string; notiTitle?: string; valid: boolean; @@ -42,9 +42,7 @@ export interface Job { // - tool: apt-get // - toolArgs: install pkg_name -export namespace Job { - -export const enum Type { +export const enum JobType { tUndefined = 0, // TODO maybe use Job.jobType = undefined? tConfig, tPrerequisites, @@ -52,5 +50,3 @@ export const enum Type { tUninstall, // TODO add more } - -} // namespace Job diff --git a/src/Job/JobCommand.ts b/src/Job/JobCommand.ts index 6c9bf3e6..a09b4aa7 100644 --- a/src/Job/JobCommand.ts +++ b/src/Job/JobCommand.ts @@ -18,12 +18,12 @@ import assert from 'assert'; import {Command} from '../Backend/Command'; -import {Job, JobCallback} from './Job'; +import {Job, JobCallback, JobType} from './Job'; import {ToolArgs} from './ToolArgs'; // NOTE: JobBase will be replaced by this class JobCommand implements Job { - jobType: Job.Type; + jobType: JobType; name: string; notiTitle?: string; valid: boolean; @@ -37,7 +37,7 @@ class JobCommand implements Job { constructor(cmd: Command) { // should be implemented by child classes - this.jobType = Job.Type.tUndefined; + this.jobType = JobType.tUndefined; this.name = ''; this.valid = false; this.workDir = require('os').homedir(); diff --git a/src/Tests/MockJob.ts b/src/Tests/MockJob.ts index 1f54c4c3..6f1ade54 100644 --- a/src/Tests/MockJob.ts +++ b/src/Tests/MockJob.ts @@ -14,11 +14,11 @@ * limitations under the License. */ -import {Job} from '../Job/Job'; +import {Job, JobType} from '../Job/Job'; import {ToolArgs} from '../Job/ToolArgs'; class MockJob implements Job { - jobType: Job.Type = Job.Type.tUndefined; + jobType: JobType = JobType.tUndefined; name: string; root: boolean = false; workDir: string = require('os').homedir(); @@ -44,7 +44,7 @@ class MockJob implements Job { } class MockFailedJob implements Job { - jobType: Job.Type = Job.Type.tUndefined; + jobType: JobType = JobType.tUndefined; name: string; root: boolean = false; workDir: string = require('os').homedir(); diff --git a/src/Tests/Toolchain/JobConfig.test.ts b/src/Tests/Toolchain/JobConfig.test.ts index 8f2a96cb..59b70b87 100644 --- a/src/Tests/Toolchain/JobConfig.test.ts +++ b/src/Tests/Toolchain/JobConfig.test.ts @@ -17,7 +17,7 @@ import {assert} from 'chai'; import {Command} from '../../Backend/Command'; -import {Job} from '../../Job/Job'; +import {JobType} from '../../Job/Job'; import {JobConfig} from '../../Toolchain/JobConfig'; suite('Toolchain', function() { @@ -33,7 +33,7 @@ suite('Toolchain', function() { assert.deepStrictEqual(job.toolArgs[0], cmd[1]); assert.deepStrictEqual(job.toolArgs[1], cmd[2]); assert.deepStrictEqual(job.name, 'config'); - assert.equal(job.jobType, Job.Type.tConfig); + assert.equal(job.jobType, JobType.tConfig); assert.isTrue(job.valid); assert.isTrue(job.isCancelable); }); diff --git a/src/Tests/Toolchain/JobInstall.test.ts b/src/Tests/Toolchain/JobInstall.test.ts index 4db2601f..adbf5a3f 100644 --- a/src/Tests/Toolchain/JobInstall.test.ts +++ b/src/Tests/Toolchain/JobInstall.test.ts @@ -17,7 +17,7 @@ import {assert} from 'chai'; import {Command} from '../../Backend/Command'; -import {Job} from '../../Job/Job'; +import {JobType} from '../../Job/Job'; import {JobInstall} from '../../Toolchain/JobInstall'; suite('Toolchain', function() { @@ -33,7 +33,7 @@ suite('Toolchain', function() { assert.deepStrictEqual(job.toolArgs[0], cmd[1]); assert.deepStrictEqual(job.toolArgs[1], cmd[2]); assert.deepStrictEqual(job.name, 'install'); - assert.equal(job.jobType, Job.Type.tInstall); + assert.equal(job.jobType, JobType.tInstall); assert.isTrue(job.valid); }); }); diff --git a/src/Tests/Toolchain/JobPrerequisites.test.ts b/src/Tests/Toolchain/JobPrerequisites.test.ts index ff13c590..3bca20c9 100644 --- a/src/Tests/Toolchain/JobPrerequisites.test.ts +++ b/src/Tests/Toolchain/JobPrerequisites.test.ts @@ -17,7 +17,7 @@ import {assert} from 'chai'; import {Command} from '../../Backend/Command'; -import {Job} from '../../Job/Job'; +import {JobType} from '../../Job/Job'; import {JobPrerequisites} from '../../Toolchain/JobPrerequisites'; suite('Toolchain', function() { @@ -31,7 +31,7 @@ suite('Toolchain', function() { assert.deepStrictEqual(job.tool, cmd[0]); assert.deepStrictEqual(job.toolArgs[0], cmd[1]); assert.deepStrictEqual(job.name, 'prerequisites'); - assert.equal(job.jobType, Job.Type.tPrerequisites); + assert.equal(job.jobType, JobType.tPrerequisites); assert.isTrue(job.valid); }); }); diff --git a/src/Tests/Toolchain/JobUninstall.test.ts b/src/Tests/Toolchain/JobUninstall.test.ts index 6d26c61a..b1b69ebb 100644 --- a/src/Tests/Toolchain/JobUninstall.test.ts +++ b/src/Tests/Toolchain/JobUninstall.test.ts @@ -17,7 +17,7 @@ import {assert} from 'chai'; import {Command} from '../../Backend/Command'; -import {Job} from '../../Job/Job'; +import {JobType} from '../../Job/Job'; import {JobUninstall} from '../../Toolchain/JobUninstall'; suite('Toolchain', function() { @@ -33,7 +33,7 @@ suite('Toolchain', function() { assert.deepStrictEqual(job.toolArgs[0], cmd[1]); assert.deepStrictEqual(job.toolArgs[1], cmd[2]); assert.deepStrictEqual(job.name, 'uninstall'); - assert.equal(job.jobType, Job.Type.tUninstall); + assert.equal(job.jobType, JobType.tUninstall); assert.isTrue(job.valid); }); }); diff --git a/src/Toolchain/JobConfig.ts b/src/Toolchain/JobConfig.ts index 0d6f9fb8..78739c91 100644 --- a/src/Toolchain/JobConfig.ts +++ b/src/Toolchain/JobConfig.ts @@ -15,17 +15,17 @@ */ import {Command} from '../Backend/Command'; -import {Job} from '../Job/Job'; +import {JobType} from '../Job/Job'; import {JobCommand} from '../Job/JobCommand'; class JobConfig extends JobCommand { - jobType: Job.Type; + jobType: JobType; name: string; valid: boolean; constructor(cmd: Command) { super(cmd); - this.jobType = Job.Type.tConfig; + this.jobType = JobType.tConfig; this.name = 'config'; this.notiTitle = 'Running onecc...'; this.valid = true; diff --git a/src/Toolchain/JobInstall.ts b/src/Toolchain/JobInstall.ts index 02f36326..6bd5c4c9 100644 --- a/src/Toolchain/JobInstall.ts +++ b/src/Toolchain/JobInstall.ts @@ -15,17 +15,17 @@ */ import {Command} from '../Backend/Command'; -import {Job} from '../Job/Job'; +import {JobType} from '../Job/Job'; import {JobCommand} from '../Job/JobCommand'; class JobInstall extends JobCommand { - jobType: Job.Type; + jobType: JobType; name: string; valid: boolean; constructor(cmd: Command) { super(cmd); - this.jobType = Job.Type.tInstall; + this.jobType = JobType.tInstall; this.name = 'install'; this.notiTitle = 'Installing the toolchain...'; this.valid = true; diff --git a/src/Toolchain/JobPrerequisites.ts b/src/Toolchain/JobPrerequisites.ts index 289d1062..591ed89b 100644 --- a/src/Toolchain/JobPrerequisites.ts +++ b/src/Toolchain/JobPrerequisites.ts @@ -15,17 +15,17 @@ */ import {Command} from '../Backend/Command'; -import {Job} from '../Job/Job'; +import {JobType} from '../Job/Job'; import {JobCommand} from '../Job/JobCommand'; class JobPrerequisites extends JobCommand { - jobType: Job.Type; + jobType: JobType; name: string; valid: boolean; constructor(cmd: Command) { super(cmd); - this.jobType = Job.Type.tPrerequisites; + this.jobType = JobType.tPrerequisites; this.name = 'prerequisites'; this.valid = true; } diff --git a/src/Toolchain/JobUninstall.ts b/src/Toolchain/JobUninstall.ts index bd2d4180..84f1b627 100644 --- a/src/Toolchain/JobUninstall.ts +++ b/src/Toolchain/JobUninstall.ts @@ -15,17 +15,17 @@ */ import {Command} from '../Backend/Command'; -import {Job} from '../Job/Job'; +import {JobType} from '../Job/Job'; import {JobCommand} from '../Job/JobCommand'; class JobUninstall extends JobCommand { - jobType: Job.Type; + jobType: JobType; name: string; valid: boolean; constructor(cmd: Command) { super(cmd); - this.jobType = Job.Type.tUninstall; + this.jobType = JobType.tUninstall; this.name = 'uninstall'; this.notiTitle = 'Uninstalling the toolchain...'; this.valid = true;