Skip to content

Commit

Permalink
fix: install deps before attempting to compile (#808)
Browse files Browse the repository at this point in the history
* fix: install deps before attempting to compile

* test: remove .only
  • Loading branch information
mdonnalley authored Feb 29, 2024
1 parent 2b8edf2 commit 98749e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export default class Plugins {
root,
userPlugins: false,
})
await this.refresh({all: true, prod: true}, plugin.root)

this.isValidPlugin(plugin)

Expand All @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions test/integration/install.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit 98749e7

Please sign in to comment.