Skip to content

Commit

Permalink
fix: only attempt tsc if tsconfig exists
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Nov 6, 2023
1 parent a2a82dc commit c06fcea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"lint": "eslint . --ext .ts",
"postpublish": "yarn run clean",
"posttest": "yarn lint",
"postinstall": "husky install",
"prepare": "husky install && yarn build",
"prepublishOnly": "yarn run build && oclif lock && oclif manifest . && oclif readme",
"pretest": "yarn build && tsc -p test --noEmit",
"preversion": "yarn run clean",
Expand Down
17 changes: 16 additions & 1 deletion src/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,32 @@ export default class Plugins {
await this.yarn.exec([...add, url], yarnOpts)
const {dependencies} = await this.pjson()
name = Object.entries(dependencies ?? {}).find(([, u]) => u === url)![0]
const root = join(this.config.dataDir, 'node_modules', name)
plugin = await Config.load({
devPlugins: false,
name,
root: join(this.config.dataDir, 'node_modules', name),
root,
userPlugins: false,
})
await this.refresh({all: true, prod: true}, plugin.root)

this.isValidPlugin(plugin)

await this.add({name, type: 'user', url})

if (
plugin.getPluginsList().find((p) => p.root === root)?.moduleType === 'module' &&
(await fileExists(join(plugin.root, 'tsconfig.json')))
) {
try {
// 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(['run', 'tsc'], {...yarnOpts, cwd: plugin.root})
} catch (error) {
this.debug(error)
}
}
} else {
// npm
const range = validRange(tag)
Expand Down

0 comments on commit c06fcea

Please sign in to comment.