Skip to content

Commit 1d217cd

Browse files
committed
refactor: Nuxi Module command
<!--- ☝️ PR title should follow conventional commits (https://conventionalcommits.org) Please carefully read the contribution docs before creating a pull request 👉 https://github.com/nuxtrdev/nuxtr-vscode/blob/main/CONTRIBUTING.md --> ### 🔗 Linked issue / Discussion <!-- Please ensure there is an open issue and mention its number as #123 --> ### ❓ Type of change <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply. --> - [ ] 📖 Documentation (updates to the documentation, readme or JSdoc annotations) - [ ] 🐞 Bug fix (a non-breaking change that fixes an issue) - [ ] 👌 Enhancement (improving an existing functionality like performance) - [ ] ✨ New feature (a non-breaking change that adds functionality) - [ ] 🧹 Chore (updates to the build process or auxiliary tools and libraries) - [x] ⚠️ Breaking change (fix or feature that would cause existing functionality to change) ### 📚 Description <!-- Describe your changes in detail --> <!-- Why is this change required? What problem does it solve? --> <!-- If it resolves an open issue, please link to the issue here. For example "Resolves #1337" --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [ ] I have linked an issue or discussion. - [ ] I have updated the documentation accordingly.
1 parent a5a166b commit 1d217cd

File tree

1 file changed

+4
-35
lines changed

1 file changed

+4
-35
lines changed

src/index.ts

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,9 @@
1-
import { workspace, ExtensionContext, commands, window } from 'vscode'
2-
import { existsSync, promises as fs } from 'fs'
3-
import { join } from 'pathe'
4-
import { isNuxtProject, getConfiguration } from './utils'
1+
import { ExtensionContext, commands } from 'vscode';
52
import { activateExtension } from './extension'
63

74
export async function activate(context: ExtensionContext) {
5+
const nuxtProject = true
86

9-
let userRoot: string | undefined
10-
11-
const configuration = getConfiguration().monorepoMode.DirectoryName
12-
13-
if (!configuration) {
14-
userRoot = workspace.workspaceFolders?.[0]?.uri.fsPath
15-
} else {
16-
userRoot = workspace.workspaceFolders?.[0]?.uri.fsPath + `/` + configuration
17-
}
18-
19-
if (!userRoot && !existsSync(`${userRoot}/package.json`)) { return }
20-
21-
const nuxtConfigPathTS = join(`${userRoot}/`, 'nuxt.config.ts')
22-
const nuxtConfigPathJS = join(`${userRoot}/`, 'nuxt.config.js')
23-
24-
const nuxtConfigExistsTS = await fs.access(nuxtConfigPathTS).then(() => true).catch(() => false)
25-
const nuxtConfigExistsJS = await fs.access(nuxtConfigPathJS).then(() => true).catch(() => false)
26-
27-
if (!nuxtConfigExistsTS && !nuxtConfigExistsJS) { return }
28-
29-
30-
const nuxtProject = await isNuxtProject()
31-
32-
if (nuxtProject) {
33-
commands.executeCommand('setContext', 'nuxtr.isNuxtProject', nuxtProject)
34-
activateExtension(context)
35-
36-
} else {
37-
commands.executeCommand('setContext', 'nuxtr.isNuxtProject', nuxtProject)
38-
window.showInformationMessage('Nuxtr: Not a Nuxt project')
39-
}
7+
commands.executeCommand('setContext', 'nuxtr.isNuxtProject', nuxtProject)
8+
activateExtension(context)
409
}

0 commit comments

Comments
 (0)