diff --git a/lib/commands/reset.js b/lib/commands/reset.js index 892c0f64..d9727645 100644 --- a/lib/commands/reset.js +++ b/lib/commands/reset.js @@ -10,8 +10,8 @@ module.exports = { let ResetTask = require('../tasks/reset'); let resetTask = new ResetTask({ - project: this.project, config, + cwd: this.project.root, }); return await resetTask.run(); diff --git a/lib/commands/try-each.js b/lib/commands/try-each.js index b58b7a08..af10e74f 100644 --- a/lib/commands/try-each.js +++ b/lib/commands/try-each.js @@ -26,8 +26,8 @@ module.exports = { debug('Config: %s', JSON.stringify(config)); let tryEachTask = new this._TryEachTask({ - project: this.project, config, + cwd: this.project.root, }); return await tryEachTask.run(config.scenarios, { skipCleanup: commandOptions.skipCleanup }); diff --git a/lib/commands/try-ember.js b/lib/commands/try-ember.js index 7ddd9556..358567e7 100644 --- a/lib/commands/try-ember.js +++ b/lib/commands/try-ember.js @@ -35,8 +35,8 @@ module.exports = { debug('Config: %s', JSON.stringify(config)); let tryEachTask = new this._TryEachTask({ - project: this.project, config, + cwd: this.project.root, }); return await tryEachTask.run(config.scenarios, { skipCleanup: commandOptions.skipCleanup }); diff --git a/lib/commands/try-one.js b/lib/commands/try-one.js index 29e7e3ec..a8ad7cfb 100644 --- a/lib/commands/try-one.js +++ b/lib/commands/try-one.js @@ -57,9 +57,9 @@ module.exports = { } let tryEachTask = new this._TryEachTask({ - project: this.project, - config, commandArgs, + config, + cwd: this.project.root, }); return await tryEachTask.run([scenario], { skipCleanup: commandOptions.skipCleanup }); diff --git a/lib/tasks/reset.js b/lib/tasks/reset.js index c258da88..5679ec85 100644 --- a/lib/tasks/reset.js +++ b/lib/tasks/reset.js @@ -7,13 +7,13 @@ const DependencyManagerAdapterFactory = require('./../utils/dependency-manager-a module.exports = class ResetTask { constructor(options) { this.config = options.config; - this.project = options.project; + this.cwd = options.cwd; } run() { let dependencyAdapters = DependencyManagerAdapterFactory.generateFromConfig( this.config, - this.project.root, + this.cwd, ); debug( 'DependencyManagerAdapters: %s', diff --git a/lib/tasks/try-each.js b/lib/tasks/try-each.js index 97eb577b..4a29619e 100644 --- a/lib/tasks/try-each.js +++ b/lib/tasks/try-each.js @@ -9,8 +9,8 @@ module.exports = class TryEachTask { this.commandArgs = options.commandArgs; this.commandOptions = options.commandOptions; this.config = options.config; + this.cwd = options.cwd; this.dependencyManagerAdapters = options.dependencyManagerAdapters; - this.project = options.project; } async run(scenarios, options) { @@ -21,7 +21,7 @@ module.exports = class TryEachTask { let dependencyManagerAdapters = this.dependencyManagerAdapters || - DependencyManagerAdapterFactory.generateFromConfig(this.config, this.project.root); + DependencyManagerAdapterFactory.generateFromConfig(this.config, this.cwd); debug( 'DependencyManagerAdapters: %s', dependencyManagerAdapters.map((item) => { @@ -134,7 +134,7 @@ module.exports = class TryEachTask { } _runCommand(options) { - return runCommand(this.project.root, options.commandArgs, options.commandOptions); + return runCommand(this.cwd, options.commandArgs, options.commandOptions); } _commandOptions(env) { diff --git a/lib/utils/dependency-manager-adapter-factory.js b/lib/utils/dependency-manager-adapter-factory.js index f4b57543..0f5b675d 100644 --- a/lib/utils/dependency-manager-adapter-factory.js +++ b/lib/utils/dependency-manager-adapter-factory.js @@ -6,7 +6,7 @@ const WorkspaceAdapter = require('../dependency-manager-adapters/workspace'); const YarnAdapter = require('../dependency-manager-adapters/yarn'); module.exports = { - generateFromConfig(config, root) { + generateFromConfig(config, cwd) { let hasNpm = false; let adapters = []; if (!config || !config.scenarios) { @@ -22,7 +22,7 @@ module.exports = { if (config.useWorkspaces) { adapters.push( new WorkspaceAdapter({ - cwd: root, + cwd, managerOptions: config.npmOptions, packageManager: config.packageManager, buildManagerOptions: config.buildManagerOptions, @@ -31,7 +31,7 @@ module.exports = { } else if (config.packageManager === 'pnpm') { adapters.push( new PnpmAdapter({ - cwd: root, + cwd, managerOptions: config.npmOptions, buildManagerOptions: config.buildManagerOptions, }), @@ -39,7 +39,7 @@ module.exports = { } else if (config.packageManager === 'yarn') { adapters.push( new YarnAdapter({ - cwd: root, + cwd, managerOptions: config.npmOptions, buildManagerOptions: config.buildManagerOptions, }), @@ -47,7 +47,7 @@ module.exports = { } else if (hasNpm) { adapters.push( new NpmAdapter({ - cwd: root, + cwd, managerOptions: config.npmOptions, buildManagerOptions: config.buildManagerOptions, }), diff --git a/test/commands/try-one-test.js b/test/commands/try-one-test.js index 02c8fc0c..80b5605a 100644 --- a/test/commands/try-one-test.js +++ b/test/commands/try-one-test.js @@ -37,6 +37,8 @@ describe('commands/try-one', () => { MockTryEachTask.prototype.run = function () {}; beforeEach(() => { + TryOneCommand.project = { root: '' }; + TryOneCommand._getConfig = function () { return Promise.resolve(mockConfig || { scenarios: [] }); }; @@ -45,6 +47,8 @@ describe('commands/try-one', () => { }); afterEach(() => { + delete TryOneCommand.project; + TryOneCommand._TryEachTask = origTryEachTask; TryOneCommand._getConfig = origGetConfig; mockConfig = null; diff --git a/test/tasks/reset-test.js b/test/tasks/reset-test.js index 53c3f872..007cafa5 100644 --- a/test/tasks/reset-test.js +++ b/test/tasks/reset-test.js @@ -37,8 +37,8 @@ describe('reset', () => { }; let resetTask = new ResetTask({ - project: { root: tmpdir }, config, + cwd: tmpdir, }); writeJSONFile('package.json', fixturePackageJson); diff --git a/test/tasks/try-each-test.js b/test/tasks/try-each-test.js index 35a391f0..60cc2f3c 100644 --- a/test/tasks/try-each-test.js +++ b/test/tasks/try-each-test.js @@ -83,8 +83,8 @@ describe('tryEach', () => { _mockLog(outputFn); let tryEachTask = new TryEachTask({ - project: { root: tmpdir }, config, + cwd: tmpdir, }); tryEachTask._on = () => {}; @@ -138,8 +138,8 @@ describe('tryEach', () => { _mockLog(outputFn); let tryEachTask = new TryEachTask({ - project: { root: tmpdir }, config, + cwd: tmpdir, }); tryEachTask._on = () => {}; @@ -203,8 +203,8 @@ describe('tryEach', () => { _mockLog(outputFn); let tryEachTask = new TryEachTask({ - project: { root: tmpdir }, config, + cwd: tmpdir, dependencyManagerAdapters: [], }); @@ -251,8 +251,8 @@ describe('tryEach', () => { _mockLog(outputFn); let tryEachTask = new TryEachTask({ - project: { root: tmpdir }, config, + cwd: tmpdir, commandArgs: ['ember', 'serve'], commandOptions: { timeout: { length: 20000, isSuccess: true } }, dependencyManagerAdapters: [new StubDependencyAdapter()], @@ -305,8 +305,8 @@ describe('tryEach', () => { _mockLog(outputFn); let tryEachTask = new TryEachTask({ - project: { root: tmpdir }, config, + cwd: tmpdir, dependencyManagerAdapters: [new StubDependencyAdapter()], }); @@ -356,8 +356,8 @@ describe('tryEach', () => { _mockLog(outputFn); let tryEachTask = new TryEachTask({ - project: { root: tmpdir }, config, + cwd: tmpdir, dependencyManagerAdapters: [new StubDependencyAdapter()], }); @@ -408,8 +408,8 @@ describe('tryEach', () => { _mockLog(outputFn); let tryEachTask = new TryEachTask({ - project: { root: tmpdir }, config, + cwd: tmpdir, dependencyManagerAdapters: [new StubDependencyAdapter()], }); @@ -463,8 +463,8 @@ describe('tryEach', () => { _mockLog(outputFn); let tryEachTask = new TryEachTask({ - project: { root: tmpdir }, config, + cwd: tmpdir, commandArgs: [], dependencyManagerAdapters: [new StubDependencyAdapter()], }); @@ -511,8 +511,8 @@ describe('tryEach', () => { _mockLog(outputFn); let tryEachTask = new TryEachTask({ - project: { root: tmpdir }, config, + cwd: tmpdir, commandArgs: ['ember', 'serve'], dependencyManagerAdapters: [new StubDependencyAdapter()], }); @@ -584,8 +584,8 @@ describe('tryEach', () => { _mockLog(outputFn); let tryEachTask = new TryEachTask({ - project: { root: tmpdir }, config, + cwd: tmpdir, dependencyManagerAdapters: [new StubDependencyAdapter()], }); @@ -632,8 +632,8 @@ describe('tryEach', () => { _mockLog(outputFn); let tryEachTask = new TryEachTask({ - project: { root: tmpdir }, config, + cwd: tmpdir, commandArgs: ['ember', 'version', '--verbose', 'true'], dependencyManagerAdapters: [new StubDependencyAdapter()], }); @@ -688,8 +688,8 @@ describe('tryEach', () => { _mockLog(outputFn); let tryEachTask = new TryEachTask({ - project: { root: tmpdir }, config, + cwd: tmpdir, dependencyManagerAdapters: [new StubDependencyAdapter()], }); @@ -742,8 +742,8 @@ describe('tryEach', () => { }; let tryEachTask = new TryEachTask({ - project: { root: tmpdir }, config, + cwd: tmpdir, dependencyManagerAdapters: [new StubDependencyAdapter()], });