Skip to content

Commit

Permalink
fix: support adding global factories
Browse files Browse the repository at this point in the history
  • Loading branch information
neikvon committed Sep 14, 2020
1 parent 1f64c8b commit ac23c66
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/commands/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@ export default class CommandCreate extends Command {

await this.install(flags || {}, targetDir)

const version = await this.getVersionInfo(targetDir)
this.store.set(`${info.name}.version`, version)
const { version, global } = await this.getVersionInfo(targetDir)
if (version) {
this.store.set(`${info.name}.version`, version)
}
if (global) {
this.store.set(`${info.name}.global`, global)
}
}
}

Expand Down Expand Up @@ -135,15 +140,18 @@ export default class CommandCreate extends Command {
private async getVersionInfo(dir: string) {
const factory = this.factory.createFactory(dir)
if (!factory) {
return
return {}
}
const config = this.context.get('config')
const factoriesDir = join(config.rootDirectory, config.directoryName)
const versionInfo = await factory.version?.init(factoriesDir)

return {
baseDir: factoriesDir,
...versionInfo
version: {
baseDir: factoriesDir,
...versionInfo
},
global: factory.isGlobal
}
}
}

0 comments on commit ac23c66

Please sign in to comment.