Skip to content

Commit

Permalink
pull out functionality of class to functions
Browse files Browse the repository at this point in the history
  • Loading branch information
XenoPOMP committed Nov 26, 2023
1 parent 72d0db3 commit e8662f0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 29 deletions.
15 changes: 5 additions & 10 deletions src/commands/generate.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Args, Command, Flags, ux } from '@oclif/core';
import WorkaroundManager from '../utils/WorkaroundManager';
import { Args, Command } from '@oclif/core';
import * as clc from 'cli-color';
import cwd from '../utils/cwd';
import appSource from '../utils/appSource';

export default class Generate extends Command {
private workaroundManager = new WorkaroundManager();

static description = 'generates code files';

static aliases = ['generate', 'g', 'gen'];
Expand All @@ -28,12 +27,8 @@ export default class Generate extends Command {

public async run(): Promise<void> {
console.log(
`Running generation script from ${clc.bold(
clc.green(this.workaroundManager.cwd()),
)}\n` +
`Script source dir ${clc.bold.yellow(
this.workaroundManager.appSource(),
)}`,
`Running generation script from ${clc.bold(clc.green(cwd()))}\n` +
`Script source dir ${clc.bold.yellow(appSource())}`,
);
}
}
19 changes: 0 additions & 19 deletions src/utils/WorkaroundManager.ts

This file was deleted.

10 changes: 10 additions & 0 deletions src/utils/appSource.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { path } from 'app-root-path';

/**
* Returns directory of script invocation.
*/
const appSource = (): string => {
return path;
};

export default appSource;
8 changes: 8 additions & 0 deletions src/utils/cwd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Returns current working directory.
*/
const cwd = (): string => {
return process.cwd();
};

export default cwd;

0 comments on commit e8662f0

Please sign in to comment.