• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript core.normalize函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中@angular-devkit/core.normalize函数的典型用法代码示例。如果您正苦于以下问题:TypeScript normalize函数的具体用法?TypeScript normalize怎么用?TypeScript normalize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了normalize函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: it

 it('can create the proper recorder (bom)', () => {
   const eBom = new SimpleFileEntry(normalize('/some/path'), Buffer.from('\uFEFFhello'));
   expect(UpdateRecorderBase.createFromFileEntry(eBom) instanceof UpdateRecorderBase).toBe(true);
   expect(UpdateRecorderBase.createFromFileEntry(eBom) instanceof UpdateRecorderBom).toBe(true);
 });
开发者ID:DevIntent,项目名称:angular-cli,代码行数:5,代码来源:recorder_spec.ts


示例2: describe

describe('Browser Builder scripts array', () => {

  const outputPath = normalize('dist');
  const scripts: { [path: string]: string } = {
    'src/input-script.js': 'console.log(\'input-script\'); var number = 1+1;',
    'src/zinput-script.js': 'console.log(\'zinput-script\');',
    'src/finput-script.js': 'console.log(\'finput-script\');',
    'src/uinput-script.js': 'console.log(\'uinput-script\');',
    'src/binput-script.js': 'console.log(\'binput-script\');',
    'src/ainput-script.js': 'console.log(\'ainput-script\');',
    'src/cinput-script.js': 'console.log(\'cinput-script\');',
    'src/lazy-script.js': 'console.log(\'lazy-script\');',
    'src/pre-rename-script.js': 'console.log(\'pre-rename-script\');',
    'src/pre-rename-lazy-script.js': 'console.log(\'pre-rename-lazy-script\');',
  };
  const getScriptsOption = () => [
    'src/input-script.js',
    'src/zinput-script.js',
    'src/finput-script.js',
    'src/uinput-script.js',
    'src/binput-script.js',
    'src/ainput-script.js',
    'src/cinput-script.js',
    { input: 'src/lazy-script.js', bundleName: 'lazy-script', lazy: true },
    { input: 'src/pre-rename-script.js', bundleName: 'renamed-script' },
    { input: 'src/pre-rename-lazy-script.js', bundleName: 'renamed-lazy-script', lazy: true },
  ];

  beforeEach(done => host.initialize().toPromise().then(done, done.fail));
  afterEach(done => host.restore().toPromise().then(done, done.fail));

  it('works', (done) => {
    const matches: { [path: string]: string } = {
      './dist/scripts.js': 'input-script',
      './dist/lazy-script.js': 'lazy-script',
      './dist/renamed-script.js': 'pre-rename-script',
      './dist/renamed-lazy-script.js': 'pre-rename-lazy-script',
      './dist/main.js': 'input-script',
      './dist/index.html': '<script type="text/javascript" src="runtime.js"></script>'
        + '<script type="text/javascript" src="polyfills.js"></script>'
        + '<script type="text/javascript" src="scripts.js"></script>'
        + '<script type="text/javascript" src="renamed-script.js"></script>'
        + '<script type="text/javascript" src="vendor.js"></script>'
        + '<script type="text/javascript" src="main.js"></script>',
    };

    host.writeMultipleFiles(scripts);
    host.appendToFile('src/main.ts', '\nimport \'./input-script.js\';');

    // Remove styles so we don't have to account for them in the index.html order check.
    const overrides = {
      styles: [],
      scripts: getScriptsOption(),
    };

    runTargetSpec(host, browserTargetSpec, overrides).pipe(
      tap((buildEvent) => expect(buildEvent.success).toBe(true)),
      tap(() => Object.keys(matches).forEach(fileName => {
        const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(fileName)));
        expect(content).toMatch(matches[fileName]);
      })),
    ).toPromise().then(done, done.fail);
  });

  it('uglifies, uses sourcemaps, and adds hashes', (done) => {
    host.writeMultipleFiles(scripts);

    const overrides = {
      optimization: true,
      sourceMap: true,
      outputHashing: 'all',
      scripts: getScriptsOption(),
    };

    runTargetSpec(host, browserTargetSpec, overrides, DefaultTimeout * 2).pipe(
      tap((buildEvent) => expect(buildEvent.success).toBe(true)),
      tap(() => {
        const scriptsBundle = host.fileMatchExists(outputPath, /scripts\.[0-9a-f]{20}\.js/);
        expect(scriptsBundle).toBeTruthy();
        const fileName = join(outputPath, scriptsBundle as PathFragment);
        const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(fileName)));
        expect(content).toMatch('var number=2;');
        expect(host.fileMatchExists(outputPath, /scripts\.[0-9a-f]{20}\.js\.map/))
          .toBeTruthy();
        expect(host.fileMatchExists(outputPath, /renamed-script\.[0-9a-f]{20}\.js/))
          .toBeTruthy();
        expect(host.fileMatchExists(outputPath, /renamed-script\.[0-9a-f]{20}\.js\.map/))
          .toBeTruthy();
        expect(host.fileMatchExists(outputPath, /scripts\.[0-9a-f]{20}\.js/)).toBeTruthy();
        expect(host.scopedSync().exists(normalize('dist/lazy-script.js'))).toBe(true);
        expect(host.scopedSync().exists(normalize('dist/lazy-script.js.map'))).toBe(true);
        expect(host.scopedSync().exists(normalize('dist/renamed-lazy-script.js'))).toBe(true);
        expect(host.scopedSync().exists(normalize('dist/renamed-lazy-script.js.map')))
          .toBe(true);
      }),
    ).toPromise().then(done, done.fail);
  });

  it('preserves script order', (done) => {
    host.writeMultipleFiles(scripts);
//.........这里部分代码省略.........
开发者ID:DevIntent,项目名称:angular-cli,代码行数:101,代码来源:scripts-array_spec_large.ts


示例3: tap

 tap(() => {
   const fileName = 'dist/index.html';
   const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(fileName)));
   expect(content).toMatch(/Welcome to app!/);
 }),
开发者ID:DevIntent,项目名称:angular-cli,代码行数:5,代码来源:app-shell_spec_large.ts


示例4: expect

 .then(() => {
   const tmpFiles = outputHost.files.sort();
   expect(tmpFiles as string[]).toEqual(files);
   expect(outputHost.sync.read(normalize('/test')).toString())
     .toBe('testing testing 1 2');
 })
开发者ID:DevIntent,项目名称:angular-cli,代码行数:6,代码来源:host_spec.ts


示例5: _mapAssets

    .map((app, idx) => {
      const defaultAppName = idx === 0 ? defaultAppNamePrefix : `${defaultAppNamePrefix}${idx}`;
      const name = app.name || defaultAppName;
      const outDir = app.outDir || defaults.outDir;
      const appRoot = app.root || defaults.appRoot;

      function _mapAssets(asset: string | JsonObject) {
        if (typeof asset === 'string') {
          return normalize(appRoot + '/' + asset);
        } else {
          if (asset.allowOutsideOutDir) {
            logger.warn(tags.oneLine`
              Asset with input '${asset.input}' was not migrated because it
              uses the 'allowOutsideOutDir' option which is not supported in Angular CLI 6.
            `);

            return null;
          } else if (asset.output) {
            return {
              glob: asset.glob,
              input: normalize(appRoot + '/' + asset.input),
              output: normalize('/' + asset.output as string),
            };
          } else {
            return {
              glob: asset.glob,
              input: normalize(appRoot + '/' + asset.input),
              output: '/',
            };
          }
        }
      }

      function _buildConfigurations(): JsonObject {
        const source = app.environmentSource;
        const environments = app.environments;
        const serviceWorker = app.serviceWorker;

        const productionPartial = {
          optimization: true,
          outputHashing: 'all',
          sourceMap: false,
          extractCss: true,
          namedChunks: false,
          aot: true,
          extractLicenses: true,
          vendorChunk: false,
          buildOptimizer: true,
          ...(serviceWorker ? {serviceWorker: true, ngswConfigPath: 'src/ngsw-config.json'} : {}),
          ...(app.budgets ? { budgets: app.budgets as JsonArray} : {}),
        };

        if (!environments) {
          return { production: productionPartial };
        }

        const configurations = Object.keys(environments).reduce((acc, environment) => {
          if (source === environments[environment]) {
            return acc;
          }

          let isProduction = false;

          const environmentContent = tree.read(app.root + '/' + environments[environment]);
          if (environmentContent) {
            isProduction = !!environmentContent.toString('utf-8')
              // Allow for `production: true` or `production = true`. Best we can do to guess.
              .match(/production['"]?\s*[:=]\s*true/);
          }

          let configurationName;
          // We used to use `prod` by default as the key, instead we now use the full word.
          // Try not to override the production key if it's there.
          if (environment == 'prod' && !environments['production'] && isProduction) {
            configurationName = 'production';
          } else {
            configurationName = environment;
          }

          acc[configurationName] = {
            ...(isProduction ? productionPartial : {}),
            fileReplacements: [
              {
                replace: `${app.root}/${source}`,
                with: `${app.root}/${environments[environment]}`,
              },
            ],
          };

          return acc;
        }, {} as JsonObject);

        if (!configurations['production']) {
          configurations['production'] = { ...productionPartial };
        }

        return configurations;
      }

      function _serveConfigurations(): JsonObject {
//.........这里部分代码省略.........
开发者ID:angular,项目名称:angular-cli,代码行数:101,代码来源:index.ts


示例6: normalize

/**
 * @license
 * Copyright Akveo. All Rights Reserved.
 * Licensed under the MIT License. See License.txt in the project root for license information.
 */

import { dirname, fragment, join, normalize, Path, PathFragment, strings } from '@angular-devkit/core';
import { DirEntry, Tree } from '@angular-devkit/schematics';

export const PREFIX = '';
export const FEATURE_MODULE_EXT = '.module.ts';
export const ROUTING_MODULE_EXT = '-routing.module.ts';
export const PLAYGROUND_PATH: Path = normalize('/src/playground/');
export const PLAYGROUND_ROUTING_MODULE_PATH: Path = join(PLAYGROUND_PATH, `playground${ROUTING_MODULE_EXT}`);

export const LAYOUT_DIR_NAME = 'with-layout';
export const LAYOUT_DIR_PATH = join(PLAYGROUND_PATH, LAYOUT_DIR_NAME);
export const LAYOUT_MODULE_PATH = join(LAYOUT_DIR_PATH, `${LAYOUT_DIR_NAME}${FEATURE_MODULE_EXT}`);
export const LAYOUT_ROUTING_MODULE_PATH = join(LAYOUT_DIR_PATH, `${LAYOUT_DIR_NAME}${ROUTING_MODULE_EXT}`);
export const LAYOUT_MODULE_CLASS = 'WithLayoutModule';
export const LAYOUT_COMPONENT_CLASS = 'PlaygroundLayoutComponent';

export const NO_LAYOUT_DIR_NAME = 'without-layout';
export const NO_LAYOUT_DIR_PATH = join(PLAYGROUND_PATH, NO_LAYOUT_DIR_NAME);
export const NO_LAYOUT_MODULE_PATH = join(NO_LAYOUT_DIR_PATH, `${NO_LAYOUT_DIR_NAME}${FEATURE_MODULE_EXT}`);
export const NO_LAYOUT_ROUTING_MODULE_PATH = join(NO_LAYOUT_DIR_PATH, `${NO_LAYOUT_DIR_NAME}${ROUTING_MODULE_EXT}`);
export const NO_LAYOUT_MODULE_CLASS = 'WithoutLayoutModule';
export const NO_LAYOUT_COMPONENT_CLASS = 'PlaygroundBaseComponent';

export const INCLUDE_DIRS: string[] = [ LAYOUT_DIR_PATH, NO_LAYOUT_DIR_PATH ];
开发者ID:kevinheader,项目名称:nebular,代码行数:30,代码来源:playground.ts


示例7: it

  it('supports isFile / isDirectory', () => {
    const host = new SyncDelegateHost(new SimpleMemoryHost());

    const buffer = stringToFileBuffer('hello');

    host.write(normalize('/sub/file1'), buffer);
    host.write(normalize('/sub/file2'), buffer);
    host.write(normalize('/sub/sub1/file3'), buffer);
    host.write(normalize('/file4'), buffer);

    expect(host.isFile(normalize('/sub'))).toBe(false);
    expect(host.isFile(normalize('/sub1'))).toBe(false);
    expect(host.isDirectory(normalize('/'))).toBe(true);
    expect(host.isDirectory(normalize('/sub'))).toBe(true);
    expect(host.isDirectory(normalize('/sub/sub1'))).toBe(true);
    expect(host.isDirectory(normalize('/sub/file1'))).toBe(false);
    expect(host.isDirectory(normalize('/sub/sub1/file3'))).toBe(false);
  });
开发者ID:fmalcher,项目名称:angular-cli,代码行数:18,代码来源:memory_spec.ts


示例8: tap

 tap(() => {
   expect(host.scopedSync().exists(normalize('./dist/folder/asset.txt'))).toBe(true);
   expect(host.scopedSync().exists(normalize('./dist/folder/asset-ignored.txt'))).toBe(false);
   expect(host.scopedSync().exists(normalize('./dist/folder/.gitkeep'))).toBe(false);
 }),
开发者ID:DevIntent,项目名称:angular-cli,代码行数:5,代码来源:assets_spec_large.ts



注:本文中的@angular-devkit/core.normalize函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript core.parseJson函数代码示例发布时间:2022-05-28
下一篇:
TypeScript core.join函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap