diff --git a/package.json b/package.json index 2fefacb5..6902531a 100644 --- a/package.json +++ b/package.json @@ -5,12 +5,12 @@ "author": "Jeff Dickey @jdxcode", "bugs": "https://github.com/anycli/test/issues", "dependencies": { - "fancy-test": "^0.6.8", + "fancy-test": "^0.6.10", "lodash": "^4.17.4" }, "devDependencies": { - "@anycli/command": "^1.2.0", - "@anycli/config": "^1.0.9", + "@anycli/command": "^1.2.1", + "@anycli/config": "^1.0.14", "@anycli/tslint": "^0.2.5", "@anycli/version": "^0.1.19", "@types/chai": "^4.1.2", diff --git a/src/command.ts b/src/command.ts index 5fdadacb..0fe166c9 100644 --- a/src/command.ts +++ b/src/command.ts @@ -1,14 +1,26 @@ -import {IConfig} from '@anycli/config' +import * as Config from '@anycli/config' import * as _ from 'lodash' import {loadConfig} from './load_config' -export default (args: string[] | string | undefined) => ({ - async run(ctx: {config: IConfig, expectation: string}) { - if (!ctx.config) ctx.config = loadConfig().run({} as any) - args = _.castArray(args) - let [cmd, ...extra] = args - ctx.expectation = ctx.expectation || `runs ${args.join(' ')}` - await ctx.config.runCommand(cmd, extra) +export function command(args: string[] | string | undefined, opts: command.Options = {}) { + return { + async run(ctx: {config: Config.IConfig, expectation: string}) { + if (!ctx.config || opts.resetConfig) { + ctx.config = loadConfig(opts.root).run({} as any) + Config.Plugin.loadedPlugins = {} + } + args = _.castArray(args) + let [cmd, ...extra] = args + ctx.expectation = ctx.expectation || `runs ${args.join(' ')}` + await ctx.config.runCommand(cmd, extra) + } } -}) +} + +export namespace command { + export interface Options { + root?: string + resetConfig?: boolean + } +} diff --git a/src/index.ts b/src/index.ts index 73951499..289e73f4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ import * as Config from '@anycli/config' import {expect, fancy, FancyTypes, NockScope} from 'fancy-test' -import command from './command' +import {command} from './command' import exit from './exit' import hook from './hook' import {loadConfig} from './load_config' @@ -19,6 +19,6 @@ export default test export { expect, FancyTypes, - NockScope, Config, + NockScope, } diff --git a/yarn.lock b/yarn.lock index 4ae3b0e8..f2bff9cb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13,9 +13,9 @@ lodash "^4.17.4" tslib "^1.9.0" -"@anycli/command@^1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@anycli/command/-/command-1.2.0.tgz#10692132c097e620f6ff5e9560fb1b6921ae146a" +"@anycli/command@^1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@anycli/command/-/command-1.2.1.tgz#026ee48b85c53850bfef28f1a08917f489f110d5" dependencies: "@anycli/parser" "^3.2.1" cli-ux "^3.3.13" @@ -35,9 +35,9 @@ lodash "^4.17.4" read-pkg "^3.0.0" -"@anycli/config@^1.0.9": - version "1.0.9" - resolved "https://registry.yarnpkg.com/@anycli/config/-/config-1.0.9.tgz#09e8e22a1586bb05d2bf4815fafe3d0674356a62" +"@anycli/config@^1.0.14": + version "1.0.14" + resolved "https://registry.yarnpkg.com/@anycli/config/-/config-1.0.14.tgz#2ffbafde6f67ee632e6614c67800d050a9575d9d" dependencies: cli-ux "^3.3.13" debug "^3.1.0" @@ -668,9 +668,9 @@ extract-stack@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/extract-stack/-/extract-stack-1.0.0.tgz#b97acaf9441eea2332529624b732fc5a1c8165fa" -fancy-test@^0.6.8: - version "0.6.8" - resolved "https://registry.yarnpkg.com/fancy-test/-/fancy-test-0.6.8.tgz#8f5f335783e8f54bd6261ba1d09b83826333ad11" +fancy-test@^0.6.10: + version "0.6.10" + resolved "https://registry.yarnpkg.com/fancy-test/-/fancy-test-0.6.10.tgz#39001bcb117b7067c851dc58da6236a08a49e267" dependencies: lodash "^4.17.4" stdout-stderr "^0.1.6"