parent
36696c4567
commit
fda19e7353
|
@ -23,7 +23,7 @@
|
|||
- 当输入 `/`开头时, 只读取`pages`或`subPackages`中的路径。
|
||||
|
||||
2. vue项目
|
||||
> 判断根目录是否有 `vue.config.js`或`vite.config.js`, 有则认为是vue项目。
|
||||
> 判断根目录有 `package.json`且有使用依赖`vue`, 有则认为是vue项目。
|
||||
- 当输入 `./` 开头时, 读取当前目录下的文件。
|
||||
- 当输入 `@/`开头时, 只读取`src/`中的路径。
|
||||
- 当输入 `/`开头时, 读取根目录的文件。
|
||||
|
|
21
index.js
21
index.js
|
@ -8,7 +8,7 @@ const vsc = require('vscode')
|
|||
const { resolve, dirname, join } = require('path')
|
||||
const fs = require('fs')
|
||||
|
||||
const FILE = vsc.CompletionItemKind.Text
|
||||
const FILE = vsc.CompletionItemKind.File
|
||||
const FOLDER = vsc.CompletionItemKind.Folder
|
||||
|
||||
/**
|
||||
|
@ -73,7 +73,7 @@ class AutoPath {
|
|||
return
|
||||
}
|
||||
|
||||
if (inputTxt.startsWith('./')) {
|
||||
if (inputTxt.startsWith('./') || inputTxt.startsWith('../')) {
|
||||
list.push(...ls(currDirFixed))
|
||||
} else {
|
||||
// 小程序
|
||||
|
@ -103,11 +103,14 @@ class AutoPath {
|
|||
}
|
||||
}
|
||||
|
||||
list = list.map(k => {
|
||||
list = list
|
||||
.filter(it => it !== doc.fileName)
|
||||
.map(k => {
|
||||
let t = options.isMiniApp ? FILE : isdir(k) ? FOLDER : FILE
|
||||
k = k.slice(currDirFixed.length)
|
||||
return item(k, t, pos)
|
||||
})
|
||||
|
||||
list.unshift(item('', FILE, pos))
|
||||
|
||||
return Promise.resolve(list)
|
||||
|
@ -119,12 +122,8 @@ function __init__() {
|
|||
|
||||
if (folders && folders.length) {
|
||||
options.workspace = folders[0].uri.path
|
||||
} else {
|
||||
options.workspace = '/opt/www/web/small-world'
|
||||
}
|
||||
|
||||
console.log()
|
||||
|
||||
if (options.workspace) {
|
||||
// 判断是否是小程序
|
||||
if (isfile(join(options.workspace, 'app.json'))) {
|
||||
|
@ -135,10 +134,9 @@ function __init__() {
|
|||
}
|
||||
}
|
||||
// 简单判断是否是vue项目
|
||||
if (
|
||||
isfile(join(options.workspace, 'vue.config.js')) ||
|
||||
isfile(join(options.workspace, 'vite.config.js'))
|
||||
) {
|
||||
if (isfile(join(options.workspace, 'package.json'))) {
|
||||
let conf = require(join(options.workspace, 'package.json'))
|
||||
if (conf.dependencies.vue) {
|
||||
let extendWorkspace = join(options.workspace, 'src/')
|
||||
if (isdir(extendWorkspace)) {
|
||||
options.extendWorkspace = extendWorkspace
|
||||
|
@ -146,6 +144,7 @@ function __init__() {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.activate = function(ctx) {
|
||||
__init__()
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"name": "auto-path",
|
||||
"displayName": "auto-path",
|
||||
"description": "🔥 自动提示文件路径, 方便引入项目为的文件",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"publisher": "yutent",
|
||||
"author": "Yutent [@yutent]",
|
||||
"icon": "logo.png",
|
||||
|
@ -28,7 +28,7 @@
|
|||
],
|
||||
"scripts": {
|
||||
"start": "esbuild index.js --bundle --outfile=out.js --external:vscode --format=cjs --platform=node",
|
||||
"vscode:prepublish": "npm start -- --minify"
|
||||
"build": "npm start -- --minify"
|
||||
},
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
|
|
Loading…
Reference in New Issue