upd: 弃用默认仓库

This commit is contained in:
purocean
2021-06-07 16:54:33 +08:00
parent 78c7013a6d
commit d01f764123
3 changed files with 5 additions and 10 deletions
-1
View File
@@ -9,7 +9,6 @@ const homedir = isWsl ? toWslPath(getWinHomePath()) : os.homedir()
export const HOME_DIR = homedir
export const USER_DIR = path.resolve((yargs.argv['data-dir'] as any) || path.join(homedir, 'yank-note'))
export const TRASH_DIR = path.join(USER_DIR, 'trash')
export const MAIN_REPO_DIR = path.join(USER_DIR, 'main')
export const CONFIG_FILE = path.join(USER_DIR, 'config.json')
export const STATIC_DIR = path.join(__dirname, '../../frontend/dist')
export const HELP_DIR = path.join(__dirname, '../../help')
+1 -4
View File
@@ -1,14 +1,11 @@
import * as fs from 'fs'
import * as path from 'path'
import { USER_DIR, TRASH_DIR, MAIN_REPO_DIR, USER_PLUGIN_DIR } from './constant'
import { USER_DIR, TRASH_DIR, USER_PLUGIN_DIR } from './constant'
const init = () => {
if (!fs.existsSync(USER_DIR)) {
fs.mkdirSync(USER_DIR)
}
if (!fs.existsSync(MAIN_REPO_DIR)) {
fs.mkdirSync(MAIN_REPO_DIR)
}
if (!fs.existsSync(TRASH_DIR)) {
fs.mkdirSync(TRASH_DIR)
}
+4 -5
View File
@@ -1,12 +1,11 @@
import * as path from 'path'
import config from './config'
import { MAIN_REPO_DIR, TRASH_DIR } from './constant'
import { isWsl, toWslPath, toWinPath } from './wsl'
import { TRASH_DIR } from './constant'
import { isWsl, toWslPath } from './wsl'
const configKey = 'repositories'
// windows 上不管是不是 wsl 环境都使用 windows 风格的路径配置
const defaultVal = { main: isWsl ? toWinPath(MAIN_REPO_DIR) : MAIN_REPO_DIR }
const defaultVal = {}
const list = () => {
return config.get(configKey, defaultVal)
@@ -21,7 +20,7 @@ const getPath = (name: string) => {
}
if (isWsl) {
return /^[a-zA-Z]:/.test(p) ? toWslPath(p) : path.join(MAIN_REPO_DIR, p)
p = /^[a-zA-Z]:/.test(p) ? toWslPath(p) : p
}
return path.isAbsolute(p) ? p : path.resolve(p)