How to use the @jupyterlab/coreutils.PathExt.resolve function in @jupyterlab/coreutils

To help you get started, we’ve selected a few @jupyterlab/coreutils 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 jupyterlab / jupyterlab / packages / filebrowser / src / crumbs.ts View on Github external
while (target && target.parentElement) {
      if (target.classList.contains(DROP_TARGET_CLASS)) {
        target.classList.remove(DROP_TARGET_CLASS);
        break;
      }
      target = target.parentElement;
    }

    // Get the path based on the target node.
    let index = ArrayExt.findFirstIndex(this._crumbs, node => node === target);
    if (index === -1) {
      return;
    }

    const model = this._model;
    const path = PathExt.resolve(model.path, BREAD_CRUMB_PATHS[index]);
    const manager = model.manager;

    // Move all of the items.
    let promises: Promise[] = [];
    let oldPaths = event.mimeData.getData(CONTENTS_MIME) as string[];
    for (let oldPath of oldPaths) {
      let localOldPath = manager.services.contents.localPath(oldPath);
      let name = PathExt.basename(localOldPath);
      let newPath = PathExt.join(path, name);
      promises.push(renameFile(manager, oldPath, newPath));
    }
    void Promise.all(promises).catch(err => {
      return showErrorMessage('Move Error', err);
    });
  }
github jupyterlab / jupyterlab / packages / docmanager / src / actions.ts View on Github external
function rename(manager: IServiceManager, oldPath: string, newPath: string, basePath = ''): Promise {
    // Normalize paths.
    oldPath = PathExt.resolve(basePath, oldPath);
    newPath = PathExt.resolve(basePath, newPath);

    return manager.contents.rename(oldPath, newPath);
  }
github jupyterlab / jupyterlab / packages / docmanager / src / actions.ts View on Github external
function rename(manager: IServiceManager, oldPath: string, newPath: string, basePath = ''): Promise {
    // Normalize paths.
    oldPath = PathExt.resolve(basePath, oldPath);
    newPath = PathExt.resolve(basePath, newPath);

    return manager.contents.rename(oldPath, newPath);
  }
github jupyterlab / jupyterlab / tests / test-coreutils / src / path.spec.ts View on Github external
it('should resolve a sequence of paths to an absolute path on the server', () => {
        const path = PathExt.resolve('var/src', '../', 'file/');
        expect(path.indexOf('var/file')).to.not.equal(-1);
      });
    });
github jupyterlab / jupyterlab / packages / filebrowser / src / model.ts View on Github external
function normalizePath(root: string, path: string): string {
    let parts = root.split(':');
    if (parts.length === 1) {
      return PathExt.resolve(root, path);
    } else {
      let resolved = PathExt.resolve(parts[1], path);
      return parts[0] + ':' + resolved;
    }
  }
}
github jupyterlab / jupyterlab / packages / filebrowser / src / model.ts View on Github external
function normalizePath(root: string, path: string): string {
    let parts = root.split(':');
    if (parts.length === 1) {
      return PathExt.resolve(root, path);
    } else {
      let resolved = PathExt.resolve(parts[1], path);
      return parts[0] + ':' + resolved;
    }
  }
}
github jupyterlab / jupyterlab / packages / docmanager / src / actions.ts View on Github external
function deleteFile(manager: IServiceManager, path: string, basePath = ''): Promise {
    path = PathExt.resolve(basePath, path);
    return stopIfNeeded(manager, path).then(() => {
      return manager.contents.delete(path);
    });
  }