Yui
Yui

Reputation: 11

vscode extensions get file from current folder

I created file keywords in the same directory where is extension.js When i try read, it's not finded.

    fs.readFile(path.resolve("~/keywords"), 'utf8', (a, b) => {
        if (a) {
            vscode.window.showInformationMessage('fail: ', a)
            return
        }
        vscode.window.showInformationMessage('ok')            
        words = JSON.parse(b)
    })

Upvotes: 1

Views: 1256

Answers (1)

James Gould
James Gould

Reputation: 4702

To access files in the same working directory as the script calling them, use:

('./file.js')

And to access 1 level below, use:

('../lib/file.js')

Upvotes: 1

Related Questions