Skip to content

Commit

Permalink
fix: add 'pkg-dir' package; remove 'tslib' package
Browse files Browse the repository at this point in the history
  • Loading branch information
neikvon committed Nov 30, 2020
1 parent 9674a03 commit 3d22602
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 73 deletions.
61 changes: 0 additions & 61 deletions PROJECT.md

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
"execa": "^4.1.0",
"fs-extra": "^9.0.1",
"ora": "^5.1.0",
"pkg-dir": "^5.0.0",
"semver": "^7.3.2",
"tiny-glob": "^0.2.8",
"tslib": "^2.0.3"
"tiny-glob": "^0.2.8"
},
"devDependencies": {
"@types/node": "*",
Expand Down
11 changes: 9 additions & 2 deletions src/core/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Command } from './command'
import { Template } from './template'
import { Plugin } from './plugin'
import { Version } from './version'
import { pathResolve } from '../utils'
import { pathResolve, pkgDir } from '../utils'

type VersionInfo = {
baseDir: string
Expand Down Expand Up @@ -41,9 +41,16 @@ export abstract class Factory extends BaseClass {
}

public init() {
if (!this.options?.rootDir) {
if (!this.options) {
return
}

this.options.rootDir = this.options.rootDir ? pkgDir.sync(this.options.rootDir) : ''

if (!this.options.rootDir) {
return
}

this.version = new Version(this.options.rootDir)

// get version number
Expand Down
15 changes: 8 additions & 7 deletions src/fbi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,15 @@ export class Fbi extends Factory {
return null
}

const idx = filePath.lastIndexOf('node_modules')
if (idx === -1) {
this.error(`Cann't resolve local factory which is not in node_modules`)
return null
}
const dir = filePath.slice(0, idx) + 'node_modules/' + targetId
// const idx = filePath.lastIndexOf('node_modules')
// console.log({ filePath, idx })
// if (idx === -1) {
// this.error(`Cann't resolve local factory which is not in node_modules`)
// return null
// }
// const dir = filePath.slice(0, idx) + 'node_modules/' + targetId

this.debug(`Factory "${targetId}" found in local`)
return this.createFactory(dir)
return this.createFactory(filePath)
}
}
3 changes: 2 additions & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fs from 'fs-extra'
import pkgDir from 'pkg-dir'

export { fs }
export { fs, pkgDir }
export * from './env'
export * from './git'
export * from './object'
Expand Down

0 comments on commit 3d22602

Please sign in to comment.