VSCode扩展API转到文件夹

时间:2018-10-10 11:17:09

标签: javascript visual-studio-code vscode-extensions

我正在为一个正在开发的项目开发扩展程序,该扩展程序现在是运行启动npm服务器的快捷方式。

我的问题是我试图转到package.json所在的文件夹,但没有到达应有的目录,即/ web文件夹。

我已经尝试执行“ cd”命令并将/ web附加到folderPath变量,但是什么也没发生。

const runJourney = vscode.commands.registerCommand('extension.runJourney', function () {
        const relativePattern = new vscode.RelativePattern(vscode.workspace.workspaceFolders[0], "*");
        const folderPath = relativePattern.base;

        exec(`cd ${folderPath}/web`, (error, stdout, stderr) => {
            if (error) {
                console.error(`couldn't find folder: ${error}`);
                return;
            }

            console.log(stderr, stdout);

            const inputOptions = {
                label: "Select your journey port",
                placeHolder: "(insert the port where the journey will run)"
            }

            vscode.window.showInputBox(inputOptions)
                .then((port) => {
                    const serverTerminal = vscode.window.createTerminal({
                        name: "serverTerminal"
                    });

                    serverTerminal.show();

                    setTimeout(() => {
                        serverTerminal.sendText(`PORT=${port} npm start`);
                    }, 1000);
                })
        });
    });

This is the result, sorry for the strikethrough but i can't reveal somethings from the company where i'm working

0 个答案:

没有答案