Skip to content

Commit

Permalink
feat(core/options): allows directory to also be defined at IScopeOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
rafamel committed Apr 27, 2019
1 parent ec911e3 commit 8b0f221
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
5 changes: 4 additions & 1 deletion src/core/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export default {
merge();
},
setScope(opts: IScopeOptions = {}): void {
// TODO: overwriting state.scope shouldn't be needed
// if we add a reset method to be called on scope change,
// that way, several options() calls within a require can accumulate;
// also, it would allow options to be optionally set on package.json
state.scope = opts;
merge();
}
Expand All @@ -42,7 +46,6 @@ function merge(): void {

// ensure cli own properties are of cli
options.file = state.cli.file || state.base.file;
options.directory = state.cli.directory || state.base.directory;

// Set logging level
if (options.log) setLevel(options.log);
Expand Down
15 changes: 6 additions & 9 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@ export interface IScripts {
}

export interface IOptions {
// TODO: env should only be part of IScopeOptions for execution
// after env are set @ process.env for cli
/**
* Project directory.
* Used for relative paths resolution and as default `cwd` on command execution.
* By default, it will be the directory in which a sibling or parent `package.json` is found for the *kpo* scripts file, or the directory of the *kpo* file itself otherwise.
*/
directory?: string | null;
/**
* Environment variables.
*/
Expand Down Expand Up @@ -95,13 +99,6 @@ export interface IScopeOptions extends IOptions {
*/
export interface IBaseOptions extends IOptions {
file?: string | null;
// TODO directory should also be possible to set @ IScopeOptions
/**
* Project directory.
* Used for relative paths resolution and as default `cwd` on command execution.
* By default, it will be the directory in which a sibling or parent `package.json` is found for the *kpo* scripts file, or the directory of the *kpo* file itself otherwise.
*/
directory?: string | null;
}

export type TCoreOptions = IBaseOptions & IScopeOptions;
Expand Down

0 comments on commit 8b0f221

Please sign in to comment.