Skip to content

Commit

Permalink
fix(factory): increase priority of local node_modules
Browse files Browse the repository at this point in the history
  • Loading branch information
neikvon committed Nov 24, 2020
1 parent 6bedf23 commit be4a4ee
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 32 deletions.
35 changes: 16 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@
"main": "lib/index.js",
"types": "lib/index.d.ts",
"bin": {
"fbi": "./bin/run"
"fbi": "bin/run"
},
"engines": {
"node": ">=10.0.0"
},
"scripts": {
"build": "rm -rf lib && tsc",
"watch": "npm run build && tsc --watch",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"posttest": "tslint -p test -t stylish",
"test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\""
"lint": "eslint . --fix",
"clean": "rm -rf lib && rm -rf node_modules"
},
"keywords": [
"fbi",
Expand All @@ -36,28 +35,26 @@
"url": "https://github.com/fbi-js/fbi/issues"
},
"dependencies": {
"@types/fs-extra": "^9.0.4",
"chalk": "^4.1.0",
"clean-stack": "^3.0.0",
"commander": "6.1.0",
"ejs": "^3.1.5",
"clean-stack": "^3.0.1",
"commander": "6.2.0",
"enquirer": "^2.3.6",
"execa": "^4.0.3",
"execa": "^4.1.0",
"fs-extra": "^9.0.1",
"ora": "^5.1.0",
"semver": "^7.3.2",
"tiny-glob": "^0.2.6",
"tiny-glob": "^0.2.8",
"tslib": "^2.0.3"
},
"devDependencies": {
"@types/ejs": "^3.0.4",
"@types/fs-extra": "^9.0.2",
"@types/node": "^14.11.8",
"@types/semver": "^7.3.4",
"@typescript-eslint/eslint-plugin": "^4.4.1",
"@typescript-eslint/parser": "^4.4.1",
"eslint": "^7.11.0",
"eslint-config-prettier": "^6.12.0",
"ts-node": "^9.0.0",
"typescript": "^4.0.3"
"@types/node": "*",
"@types/semver": "^7",
"@typescript-eslint/eslint-plugin": "^4",
"@typescript-eslint/parser": "^4",
"eslint": "^7",
"eslint-config-prettier": "^6",
"ts-node": "^9",
"typescript": "^4"
}
}
12 changes: 6 additions & 6 deletions src/commands/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default class CommandList extends Command {
// commands list
txt += '\n'
if (isValidArray(obj.commands)) {
let title = '\n Commands:'
const title = '\n Commands:'
txt += title
for (const cmd of obj.commands) {
const disabled = isFunction(cmd.disable) ? await cmd.disable() : cmd.disable
Expand All @@ -134,7 +134,7 @@ export default class CommandList extends Command {

// templates list
if (isValidArray(obj.templates)) {
let title = '\n\n Templates:'
const title = '\n\n Templates:'
txt += title
for (const t of obj.templates) {
txt += this.colWrap(
Expand Down Expand Up @@ -185,7 +185,7 @@ export default class CommandList extends Command {
)
if (isValidArray(projects)) {
txt += '\n\n Projects:'
for (let project of projects) {
for (const project of projects) {
// check if project exist
const exist = await this.fs.pathExists(project.path)
if (exist) {
Expand All @@ -204,9 +204,9 @@ export default class CommandList extends Command {
private lines(
str: string,
width: number = screenColumns - this.padWidth,
indent: number = 0,
minWidth: boolean = false,
wordBreak: boolean = false
indent = 0,
minWidth = false,
wordBreak = false
) {
if (str.match(/[\n]\s+/)) return [str]
let lines = []
Expand Down
2 changes: 1 addition & 1 deletion src/commands/remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default class CommandRemove extends Command {

// remove version dirs
if (factory?.version?.versions) {
for (let version of factory.version.versions) {
for (const version of factory.version.versions) {
await this.fs.remove(join(factory.version.baseDir, `${factory.id}__${version.short}`))
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/fbi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ export class Fbi extends Factory {
return found
}

found = this.resolveFromGlobal(targetId, targetVersion)
found = this.resolveFromLocal(targetId, targetVersion)
if (found) {
return found
}

return this.resolveFromLocal(targetId, targetVersion)
return this.resolveFromGlobal(targetId, targetVersion)
}

public resolveGlobalFactories() {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const formatDuration = (ms: number) => {
millisecond: Math.floor(ms) % 1000
}
return Object.entries(time)
.filter(val => val[1] !== 0)
.filter((val) => val[1] !== 0)
.map(([key, val]) => `${val} ${key}${val !== 1 ? 's' : ''}`)
.join(', ')
}
Expand All @@ -21,7 +21,7 @@ export function formatName(str: string | [], separator = '-') {
.split(/[^0-9a-zA-Z]/)
.filter(Boolean)
.join(separator)
return Array.isArray(str) ? str.filter(Boolean).map(t => format(t)) : format(str)
return Array.isArray(str) ? str.filter(Boolean).map((t) => format(t)) : format(str)
}

// Example: HTMLInputElement => html-input-element
Expand Down
2 changes: 1 addition & 1 deletion src/utils/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const shallowClone = (obj: AnyObject) => Object.assign({}, obj)
export const deepClone = (obj: any) => {
const clone = Object.assign({}, obj)
Object.keys(clone).forEach(
key => (clone[key] = typeof obj[key] === 'object' ? deepClone(obj[key]) : obj[key])
(key) => (clone[key] = typeof obj[key] === 'object' ? deepClone(obj[key]) : obj[key])
)
return isArray(obj) && obj.length
? (clone.length = obj.length) && Array.from(clone)
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"compilerOptions": {
"declaration": true,
"importHelpers": true,
"module": "commonjs",
"outDir": "./lib",
"strict": true,
Expand Down

0 comments on commit be4a4ee

Please sign in to comment.