How to use the @theia/workspace/lib/common.getTemporaryWorkspaceFileUri function in @theia/workspace

To help you get started, we’ve selected a few @theia/workspace examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eclipse-theia / theia / packages / plugin-ext / src / main / node / paths / plugin-paths-service.ts View on Github external
protected async buildWorkspaceId(workspace: FileStat, roots: FileStat[]): Promise {
        const homeDir = await this.getUserHomeDir();
        const untitledWorkspace = getTemporaryWorkspaceFileUri(new URI(homeDir));

        if (untitledWorkspace.toString() === workspace.uri) {
            // if workspace is temporary
            // then let create a storage path for each set of workspace roots
            const rootsStr = roots.map(root => root.uri).sort().join(',');
            return crypto.createHash('md5').update(rootsStr).digest('hex');
        } else {
            const uri = new URI(workspace.uri);
            let displayName = uri.displayName;

            if ((!workspace || !workspace.isDirectory) && (displayName.endsWith(`.${THEIA_EXT}`) || displayName.endsWith(`.${VSCODE_EXT}`))) {
                displayName = displayName.slice(0, displayName.lastIndexOf('.'));
            }

            return crypto.createHash('md5').update(uri.toString()).digest('hex');
        }

@theia/workspace

Theia - Workspace Extension

EPL-2.0
Latest version published 14 days ago

Package Health Score

87 / 100
Full package analysis