How to use the @angular-devkit/core.basename function in @angular-devkit/core

To help you get started, we’ve selected a few @angular-devkit/core 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 nrwl / nx / packages / web / src / utils / third-party / utils / normalize-asset-patterns.ts View on Github external
let isDirectory = false;

      try {
        isDirectory = host.isDirectory(resolvedAssetPath);
      } catch {
        isDirectory = true;
      }

      if (isDirectory) {
        // Folders get a recursive star glob.
        glob = '**/*';
        // Input directory is their original path.
        input = assetPath;
      } else {
        // Files are their own glob.
        glob = basename(assetPath);
        // Input directory is their original dirname.
        input = dirname(assetPath);
      }

      // Output directory for both is the relative path from source root to input.
      output = relative(resolvedSourceRoot, resolve(root, input));

      // Return the asset pattern in object format.
      return { glob, input, output };
    } else {
      // It's already an AssetPatternObject, no need to convert.
      return assetPattern;
    }
  });
}
github storybookjs / storybook / app / angular / src / server / angular-cli_utils.ts View on Github external
function getAssetsParts(resolvedAssetPath: Path, assetPath: Path) {
  if (isDirectory(resolvedAssetPath)) {
    return {
      glob: '**/*', // Folders get a recursive star glob.
      input: assetPath, // Input directory is their original path.
    };
  }

  return {
    glob: basename(assetPath), // Files are their own glob.
    input: dirname(assetPath), // Input directory is their original dirname.
  };
}
github rxweb / rxweb / rxweb.io / node_modules / @angular-devkit / build-angular / src / angular-cli-files / models / webpack-configs / utils.js View on Github external
return extraEntryPoints.map(entry => {
        let normalizedEntry;
        if (typeof entry === 'string') {
            normalizedEntry = { input: entry, lazy: false, bundleName: defaultBundleName };
        }
        else {
            let bundleName;
            if (entry.bundleName) {
                bundleName = entry.bundleName;
            }
            else if (entry.lazy) {
                // Lazy entry points use the file name as bundle name.
                bundleName = core_1.basename(core_1.normalize(entry.input.replace(/\.(js|css|scss|sass|less|styl)$/i, '')));
            }
            else {
                bundleName = defaultBundleName;
            }
            normalizedEntry = Object.assign({}, entry, { bundleName });
        }
        return normalizedEntry;
    });
}
github storybookjs / storybook / app / angular / src / server / angular-cli_utils.ts View on Github external
function getAssetsParts(resolvedAssetPath: Path, assetPath: Path) {
  if (isDirectory(resolvedAssetPath)) {
    return {
      glob: '**/*', // Folders get a recursive star glob.
      input: assetPath, // Input directory is their original path.
    };
  }

  return {
    glob: basename(assetPath), // Files are their own glob.
    input: dirname(assetPath), // Input directory is their original dirname.
  };
}
github akveo / nebular / schematics / utils / path.ts View on Github external
export function importPath(from: Path, to: Path): string {
  const relativePath = relative(dirname(from), dirname(to));

  if (relativePath.startsWith('.')) {
    return relativePath;
  }

  if (!relativePath) {
    return generateCurrentDirImport(basename(to));
  }

  return generateCurrentDirImport(join(relativePath, basename(to)));
}
github johandb / svg-drawing-tool / node_modules / @schematics / angular / universal / index.js View on Github external
return (host, context) => {
        const clientProject = project_1.getProject(host, options.clientProject);
        if (clientProject.projectType !== 'application') {
            throw new schematics_1.SchematicsException(`Universal requires a project type of "application".`);
        }
        const clientTargets = project_targets_1.getProjectTargets(clientProject);
        const outDir = getTsConfigOutDir(host, clientTargets);
        if (!clientTargets.build) {
            throw project_targets_1.targetBuildNotFoundError();
        }
        const tsConfigExtends = core_1.basename(core_1.normalize(clientTargets.build.options.tsConfig));
        const rootInSrc = clientProject.root === '';
        const tsConfigDirectory = core_1.join(core_1.normalize(clientProject.root), rootInSrc ? 'src' : '');
        if (!options.skipInstall) {
            context.addTask(new tasks_1.NodePackageInstallTask());
        }
        const templateSource = schematics_1.apply(schematics_1.url('./files/src'), [
            schematics_1.template(Object.assign({}, core_1.strings, options, { stripTsExtension: (s) => s.replace(/\.ts$/, '') })),
            schematics_1.move(core_1.join(core_1.normalize(clientProject.root), 'src')),
        ]);
        const rootSource = schematics_1.apply(schematics_1.url('./files/root'), [
            schematics_1.template(Object.assign({}, core_1.strings, options, { stripTsExtension: (s) => s.replace(/\.ts$/, ''), outDir,
                tsConfigExtends,
                rootInSrc })),
            schematics_1.move(tsConfigDirectory),
        ]);
        return schematics_1.chain([
github ngxs / schematics / src / utils / parser.ts View on Github external
public nameParser(options: ParseOptions): Location {
    const nameWithoutPath: string = basename(options.name as Path);
    const namePath: string = dirname((options.path === undefined ? '' : options.path)
      .concat('/')
      .concat(options.name) as Path);
    return {
      name: nameWithoutPath,
      path: normalize('/'.concat(namePath))
    };
  }
github angular / angular-cli / packages / schematics / angular / utility / parse-name.ts View on Github external
export function parseName(path: string, name: string): Location {
  const nameWithoutPath = basename(normalize(name));
  const namePath = dirname(join(normalize(path), name) as Path);

  return {
    name: nameWithoutPath,
    path: normalize('/' + namePath),
  };
}
github devonfw / devon4node / packages / schematics / src / lib / controller / controller.factory.ts View on Github external
export function main(options: IControllerOptions): Rule {
  const name = strings.dasherize(basename(options.name as Path));
  const fullName = strings.dasherize(join(dirname(options.name as Path), pluralize.plural(name)));
  const projectPath = options.path || '.';
  const path: Path = strings.dasherize(normalize(join(projectPath as Path, 'src/app', options.name, '..'))) as Path;

  return chain([
    mergeWith(
      apply(url('./files'), [
        options.spec ? noop() : filter(p => !p.endsWith('.spec.ts')),
        template({
          ...strings,
          name,
          fullName,
        }),
        move(path),
        formatTsFiles(),
      ]),
github rxweb / rxweb / rxweb.io / node_modules / @schematics / angular / universal / index.js View on Github external
return (host, context) => {
        const clientProject = getClientProject(host, options);
        if (clientProject.projectType !== 'application') {
            throw new schematics_1.SchematicsException(`Universal requires a project type of "application".`);
        }
        const clientArchitect = getClientArchitect(host, options);
        const outDir = getTsConfigOutDir(host, clientArchitect);
        const tsConfigExtends = core_1.basename(clientArchitect.build.options.tsConfig);
        const rootInSrc = clientProject.root === '';
        const tsConfigDirectory = core_1.join(core_1.normalize(clientProject.root), rootInSrc ? 'src' : '');
        if (!options.skipInstall) {
            context.addTask(new tasks_1.NodePackageInstallTask());
        }
        const templateSource = schematics_1.apply(schematics_1.url('./files/src'), [
            schematics_1.template(Object.assign({}, core_1.strings, options, { stripTsExtension: (s) => { return s.replace(/\.ts$/, ''); } })),
            schematics_1.move(core_1.join(core_1.normalize(clientProject.root), 'src')),
        ]);
        const rootSource = schematics_1.apply(schematics_1.url('./files/root'), [
            schematics_1.template(Object.assign({}, core_1.strings, options, { stripTsExtension: (s) => { return s.replace(/\.ts$/, ''); }, outDir,
                tsConfigExtends,
                rootInSrc })),
            schematics_1.move(tsConfigDirectory),
        ]);
        return schematics_1.chain([