How to use the @boost/common.Path.create function in @boost/common

To help you get started, we’ve selected a few @boost/common 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 milesj / boost / packages / core / src / ModuleLoader.ts View on Github external
importModule(name: string | Path, args: any[] = []): Tm {
    const { typeName } = this;
    const { appName, scoped } = this.tool.options;

    // Determine modules to attempt to load
    const modulesToAttempt = [];
    let isFilePath = false;
    let importedModule: any = null;
    let moduleName;

    // File path
    if (name instanceof Path || name.match(/^\.|\/|\\|[A-Z]:/u)) {
      this.debug('Locating %s from path %s', typeName, color.filePath(name));

      modulesToAttempt.push(Path.create(name).path());
      isFilePath = true;

      // Module name
    } else {
      this.debug('Locating %s module %s', typeName, color.moduleName(name));

      if (scoped) {
        modulesToAttempt.push(formatModuleName(appName, typeName, name, true));
      }

      modulesToAttempt.push(formatModuleName(appName, typeName, name));

      // Additional scopes to load
      this.scopes.forEach(otherScope => {
        modulesToAttempt.push(
          formatModuleName(otherScope, typeName, name, true),
github milesj / boost / packages / core / src / ConfigLoader.ts View on Github external
findConfigInWorkspaceRoot(root: PortablePath): ConfigPathOrObject | null {
    const rootPath = Path.create(root);
    let currentPath = rootPath.parent();
    let currentDir = currentPath.path();

    if (currentDir.includes('node_modules')) {
      return null;
    }

    this.debug('Detecting if in a workspace');

    let workspaceRoot: Path | null = null;
    let workspacePackage: any = {};
    let workspacePatterns: string[] = [];

    // eslint-disable-next-line no-constant-condition
    while (true) {
      if (!currentDir || currentDir === '.' || currentDir === '/') {
github milesj / boost / packages / core / src / Tool.ts View on Github external
getWorkspacePaths(options: WorkspaceOptions = {}): FilePath[] {
    const rootPath = Path.create(options.root || this.options.root);
    const pkgPath = rootPath.append('package.json');
    const lernaPath = rootPath.append('lerna.json');
    const workspacePaths = [];

    // Yarn
    if (pkgPath.exists()) {
      const pkg = fs.readJsonSync(pkgPath.path());

      if (pkg.workspaces) {
        if (Array.isArray(pkg.workspaces)) {
          workspacePaths.push(...pkg.workspaces);
        } else if (Array.isArray(pkg.workspaces.packages)) {
          workspacePaths.push(...pkg.workspaces.packages);
        }
      }
    }
github milesj / boost / packages / core / src / Tool.ts View on Github external
createWorkspaceMetadata(jsonPath: PortablePath): WorkspaceMetadata {
    const metadata: any = {};
    const filePath = Path.create(jsonPath);
    const pkgPath = filePath.parent();
    const wsPath = pkgPath.parent();

    metadata.jsonPath = filePath.path();
    metadata.packagePath = pkgPath.path();
    metadata.packageName = pkgPath.name();
    metadata.workspacePath = wsPath.path();
    metadata.workspaceName = wsPath.name();

    return metadata;
  }