Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Commit

Permalink
refactor: remove font-manager and platform-folders dependecies
Browse files Browse the repository at this point in the history
  • Loading branch information
nysos3 committed Mar 8, 2019
1 parent 0bfd868 commit 121bfc7
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 80 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
"**/lib-es5": true
},
"eslint.enable": true,
"git.enableCommitSigning": true
}
6 changes: 3 additions & 3 deletions lib/actions/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'path'
import fs from 'fs-extra'
import inquirer from 'inquirer'
import chalk from 'chalk'
import { getConfigHome } from 'platform-folders'
import appData from '../utils/app-data'
import emoji from '../utils/emoji'
import installSkin from '../utils/install-skin'
import repoHelper from '../utils/repo-helper'
Expand Down Expand Up @@ -95,11 +95,11 @@ async function askForInstallPath (state) {

if (defaultLocation === '') {
if (os.type() === 'Darwin') {
defaultLocation = path.resolve(getConfigHome(), 'Steam', 'Steam.AppBundle', 'Steam', 'Contents', 'MacOS', 'skins')
defaultLocation = path.resolve(appData('Steam'), 'Steam.AppBundle', 'Steam', 'Contents', 'MacOS', 'skins')
} else if (os.type() === 'Windows_NT') {
defaultLocation = 'C:\\Program Files (x86)\\Steam\\skins'
} else if (os.type() === 'Linux') {
defaultLocation = path.resolve(os.userInfo().homedir, '.steam/skins')
defaultLocation = path.resolve(appData('steam'), 'skins')
}

if (!fs.existsSync(defaultLocation)) {
Expand Down
12 changes: 12 additions & 0 deletions lib/utils/app-data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import os from 'os'
import path from 'path'

export default (...app) => {
if (os.type() === 'Darwin') {
return path.join(process.env.HOME, 'Library', 'Application Support', ...app)
} else if (os.type() === 'Windows_NT') {
return path.join(process.env.APPDATA, ...app)
} else {
return path.join(process.env.HOME, '.config', ...app)
}
}
6 changes: 2 additions & 4 deletions lib/utils/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from 'path'
import fs from 'fs-extra'
import chalk from 'chalk'
import extend from 'xtend'
import { getConfigHome } from 'platform-folders'
import appData from './app-data'

function init (state) {
if (JSON.stringify(read(state)) === '{}' || JSON.stringify(read(state)) === '') {
Expand All @@ -18,9 +18,7 @@ function init (state) {
}

function determineLocation (state) {
// https://github.com/kingjan1999/platform-folders#readme
const rootConfigDir = getConfigHome()
const configDir = path.resolve(rootConfigDir, 'airforsteam-cli')
const configDir = appData('airforsteam-cli')
if (state.get('configDir') !== '') {
return
}
Expand Down
7 changes: 5 additions & 2 deletions lib/utils/font-helper.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint-disable no-unreachable */
import os from 'os'
import path from 'path'
import fs from 'fs-extra'
import fontManager from 'font-manager'
// import fontManager from 'font-manager'
import chalk from 'chalk'
import execa from 'execa'
import inquirer from 'inquirer'
Expand Down Expand Up @@ -52,6 +53,8 @@ const skinFonts = {
}

async function init (state, force = false) {
// functionality temporarily disabled.
return true
if (!state.get('firstRun') && !force) {
return true
}
Expand All @@ -66,7 +69,7 @@ async function init (state, force = false) {
let installedFonts = {}

fontConfig.search.forEach((fontSearch) => {
fontManager.findFontsSync(fontSearch).forEach((font) => { installedFonts[font.postscriptName] = font })
// fontManager.findFontsSync(fontSearch).forEach((font) => { installedFonts[font.postscriptName] = font })
})
installedFonts = Object.keys(installedFonts)

Expand Down
82 changes: 16 additions & 66 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,11 @@
"chalk": "^2.4.2",
"etl": "^0.5.19",
"execa": "^1.0.0",
"font-manager": "^0.3.0",
"fs-extra": "^7.0.1",
"inquirer": "^6.2.2",
"meow": "^5.0.0",
"node-emoji": "^1.10.0",
"ora": "^3.2.0",
"platform-folders": "^0.4.0",
"register-service-worker": "^1.5.2",
"unzipper": "^0.9.11",
"update-notifier": "^2.5.0",
Expand Down
6 changes: 3 additions & 3 deletions src/components/TheHome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ import { remote } from 'electron'
import os from 'os'
import path from 'path'
import fs from 'fs'
import { getConfigHome } from 'platform-folders'
import appData from '../../lib/utils/app-data'
export default {
data: () => ({
Expand Down Expand Up @@ -142,11 +142,11 @@ export default {
let defaultPath = JSON.parse(JSON.stringify(this.steamSkinFolder))
if (defaultPath === '') {
if (os.type() === 'Darwin') {
defaultPath = path.resolve(getConfigHome(), 'Steam', 'Steam.AppBundle', 'Steam', 'Contents', 'MacOS', 'skins')
defaultPath = path.resolve(appData('Steam'), 'Steam.AppBundle', 'Steam', 'Contents', 'MacOS', 'skins')
} else if (os.type() === 'Windows_NT') {
defaultPath = 'C:\\Program Files (x86)\\Steam\\skins'
} else if (os.type() === 'Linux') {
defaultPath = path.resolve(os.userInfo().homedir, '.steam/skins')
defaultPath = path.resolve(appData('steam'), 'skins')
}
if (!fs.existsSync(defaultPath)) {
Expand Down

0 comments on commit 121bfc7

Please sign in to comment.