Skip to content

Commit f995efb

Browse files
committed
Fixed path for MacOS
1 parent 665d368 commit f995efb

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/treeview.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const fs = require('fs')
55

66
class Treeview {
77
constructor(context) {
8-
const specTreeDataProvider = new SpecTreeDataProvider(vscode.workspace.rootPath)
8+
const specTreeDataProvider = new SpecTreeDataProvider(vscode.workspace.workspaceFolders[0].uri.fsPath)
99
context.subscriptions.push(vscode.workspace.registerTextDocumentContentProvider('spec', specTreeDataProvider))
1010
this.specExplorer = vscode.window.createTreeView('spec-explorer', { treeDataProvider: specTreeDataProvider, showCollapseAll: true })
1111
}
@@ -45,10 +45,10 @@ class SpecTreeDataProvider {
4545
}
4646

4747
getFiles(thePath) {
48-
const toFileItem = (name, path, type) => {
48+
const toFileItem = (name, targetPath, type) => {
4949
if (type == 'directory') {
5050
let descriptionText, collapsibleState
51-
const filesCount = fs.readdirSync(`${path}\\${name}`).filter(this.isMp3).length
51+
const filesCount = fs.readdirSync(path.join(targetPath, name)).filter(this.isMp3).length
5252
if (filesCount > 0) {
5353
collapsibleState = vscode.TreeItemCollapsibleState.Collapsed
5454
descriptionText = `${filesCount} song`
@@ -57,9 +57,9 @@ class SpecTreeDataProvider {
5757
collapsibleState = vscode.TreeItemCollapsibleState.None
5858
descriptionText = 'Empty'
5959
}
60-
return new fileItem(name, path, collapsibleState, descriptionText)
60+
return new fileItem(name, targetPath, collapsibleState, descriptionText)
6161
} else {
62-
return new fileItem(name, path, vscode.TreeItemCollapsibleState.None)
62+
return new fileItem(name, targetPath, vscode.TreeItemCollapsibleState.None)
6363
}
6464
}
6565
const isDirectory = name => fs.lstatSync(path.join(thePath, name)).isDirectory()
@@ -84,13 +84,13 @@ class fileItem extends vscode.TreeItem {
8484
this.label = label
8585
this.collapsibleState = collapsibleState
8686
this.filePath = filePath
87-
this.fullFilePath = `${this.filePath}\\${this.label}`
87+
this.fullFilePath = path.join(this.filePath, this.label)
8888
this.command = command
8989
this.contextValue = 'dependency'
9090
this.descriptionText = descriptionText
9191
}
9292
get tooltip() {
93-
return `${this.filePath}\\${this.label}`
93+
return path.join(this.filePath, this.label)
9494
}
9595
get description() {
9696
return this.descriptionText

src/webview.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class SpecWebviewPanel {
2626

2727
const panel = vscode.window.createWebviewPanel(SpecWebviewPanel.viewType, 'Spectrogam', column || vscode.ViewColumn.One, {
2828
enableScripts: true,
29-
// localResourceRoots: [vscode.Uri.file(path.join(extensionPath, 'media'))]
29+
localResourceRoots: [vscode.Uri.file(vscode.workspace.workspaceFolders[0].uri.fsPath)]
3030
})
3131
SpecWebviewPanel.currentPanel = new SpecWebviewPanel(panel, extensionPath)
3232
}
@@ -55,7 +55,7 @@ class SpecWebviewPanel {
5555
const semjs_uri = vscode.Uri.file(semjs_path).with({ scheme: 'vscode-resource' })
5656
const semcss_uri = vscode.Uri.file(semcss_path).with({ scheme: 'vscode-resource' })
5757
const jquery_uri = vscode.Uri.file(jquery_path).with({ scheme: 'vscode-resource' })
58-
const compiledFunction = pug.compileFile(`${__dirname}\\index.pug`)
58+
const compiledFunction = pug.compileFile(path.join(__dirname, 'index.pug'))
5959

6060
return compiledFunction({
6161
bundle_uri: bundle_uri,

0 commit comments

Comments
 (0)