export async function getDeployFsPath()

in appservice/src/deploy/getDeployFsPath.ts [23:77]


export async function getDeployFsPath(context: IActionContext, target: vscode.Uri | string | AzExtTreeItem | undefined, fileExtensions?: string | string[]): Promise<IDeployPaths> {
    let originalDeployFsPath: string | undefined;
    let effectiveDeployFsPath: string | undefined;
    let workspaceFolder: vscode.WorkspaceFolder | undefined;
    if (target instanceof vscode.Uri) {
        originalDeployFsPath = target.fsPath;
        workspaceFolder = vscode.workspace.getWorkspaceFolder(target);
        effectiveDeployFsPath = await appendDeploySubpathSetting(context, workspaceFolder, target.fsPath);
    } else if (typeof target === 'string') {
        originalDeployFsPath = target;
        workspaceFolder = vscode.workspace.getWorkspaceFolder(vscode.Uri.file(target));
        effectiveDeployFsPath = await appendDeploySubpathSetting(context, workspaceFolder, target);
    } else if (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length === 1) {
        // If there is only one workspace and it has 'deploySubPath' set - return that value without prompting
        const singleWorkspace = vscode.workspace.workspaceFolders[0];
        const deploySubpath: string | undefined = getWorkspaceSetting(deploySubpathSetting, ext.prefix, singleWorkspace);
        if (deploySubpath) {
            context.telemetry.properties.hasDeploySubpathSetting = 'true';
            originalDeployFsPath = singleWorkspace.uri.fsPath;
            effectiveDeployFsPath = path.join(singleWorkspace.uri.fsPath, deploySubpath);
            workspaceFolder = singleWorkspace;
        }
    }

    if (!originalDeployFsPath || !effectiveDeployFsPath) {
        if (typeof fileExtensions === 'string') {
            fileExtensions = [fileExtensions];
        }

        const selectFile: string = localize('selectDeployFile', 'Select the {0} file to deploy', fileExtensions ? fileExtensions.join('/') : '');
        const selectFolder: string = localize('selectDeployFolder', 'Select the folder to deploy');

        const selectedItem = fileExtensions ?
            await workspaceUtil.selectWorkspaceFile(context, selectFile, fileExtensions) :
            await workspaceUtil.selectWorkspaceFolder(context, selectFolder);
        if (selectedItem instanceof vscode.Uri) {
            originalDeployFsPath = selectedItem.fsPath;
            workspaceFolder = vscode.workspace.getWorkspaceFolder(selectedItem);
        } else {
            originalDeployFsPath = selectedItem.uri.fsPath;
            workspaceFolder = selectedItem;
        }

        effectiveDeployFsPath = await appendDeploySubpathSetting(context, workspaceFolder, originalDeployFsPath);
    }

    void addRuntimeFileTelemetry(context, effectiveDeployFsPath);

    if (!workspaceFolder) {
        promptToOpenWorkspace(context, originalDeployFsPath);
    }

    context.telemetry.properties.deployingSubpathOfWorkspace = String(isSubpath(workspaceFolder.uri.fsPath, effectiveDeployFsPath));
    return { originalDeployFsPath, effectiveDeployFsPath, workspaceFolder };
}