From 98749e7dae176933134339f11f534e2e321ca131 Mon Sep 17 00:00:00 2001 From: Mike Donnalley Date: Thu, 29 Feb 2024 09:50:16 -0700 Subject: [PATCH] fix: install deps before attempting to compile (#808) * fix: install deps before attempting to compile * test: remove .only --- src/plugins.ts | 4 +++- test/integration/install.integration.ts | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/plugins.ts b/src/plugins.ts index 37e30b20..f684ea66 100644 --- a/src/plugins.ts +++ b/src/plugins.ts @@ -95,7 +95,6 @@ export default class Plugins { root, userPlugins: false, }) - await this.refresh({all: true, prod: true}, plugin.root) this.isValidPlugin(plugin) @@ -109,11 +108,14 @@ export default class Plugins { // CJS plugins can be auto-transpiled at runtime but ESM plugins // cannot. To support ESM plugins we need to compile them after // installing them. + await this.yarn.exec(['install'], {...yarnOpts, cwd: plugin.root}) await this.yarn.exec(['run', 'tsc'], {...yarnOpts, cwd: plugin.root}) } catch (error) { this.debug(error) } } + + await this.refresh({all: true, prod: true}, plugin.root) } else { // npm const range = validRange(tag) diff --git a/test/integration/install.integration.ts b/test/integration/install.integration.ts index 10dbaf24..94748b44 100644 --- a/test/integration/install.integration.ts +++ b/test/integration/install.integration.ts @@ -119,11 +119,14 @@ describe('install/uninstall integration tests', () => { const result = await PluginsIndex.run([], cwd) expect(stdoutStub.calledWith(match('test-esm-1'))).to.be.true - expect(result.some((r) => r.name === '@oclif/plugin-test-esm-1')).to.be.true + expect( + result.some((r) => r.name === '@oclif/plugin-test-esm-1'), + 'plugin to be installed', + ).to.be.true // test that the plugin was compiled after install (only applies to github installs) const compiledDir = join(dataDir, 'node_modules', '@oclif', 'plugin-test-esm-1', 'dist') - expect(existsSync(compiledDir)).to.be.true + expect(existsSync(compiledDir), 'compiled dir to exist').to.be.true }) it('should uninstall plugin from github', async () => {