当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Tree.delete方法代码示例

本文整理汇总了TypeScript中@angular-devkit/schematics.Tree.delete方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Tree.delete方法的具体用法?TypeScript Tree.delete怎么用?TypeScript Tree.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@angular-devkit/schematics.Tree的用法示例。


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

示例1: return

  return (tree: Tree, context: SchematicContext) => {
    for (let file of options.deleteFiles) {
      tree.delete(file);
    }

    context.addTask(new RunSchematicTask('ng-post-post-update', {}));
  };
开发者ID:fricker,项目名称:material2,代码行数:7,代码来源:update.ts

示例2: return

  return (host: Tree, context: SchematicContext) => {
    const oldConfigPath = getConfigPath(host);
    const configPath = normalize('angular.json');
    context.logger.info(`Updating configuration`);
    const config: JsonObject = {
      '$schema': './node_modules/@angular/cli/lib/config/schema.json',
      version: 1,
      newProjectRoot: 'projects',
      projects: extractProjectsConfig(oldConfig, host, logger),
    };
    const defaultProject = extractDefaultProject(oldConfig);
    if (defaultProject !== null) {
      config.defaultProject = defaultProject;
    }
    const cliConfig = extractCliConfig(oldConfig);
    if (cliConfig !== null) {
      config.cli = cliConfig;
    }
    const schematicsConfig = extractSchematicsConfig(oldConfig);
    if (schematicsConfig !== null) {
      config.schematics = schematicsConfig;
    }
    const targetsConfig = extractTargetsConfig(oldConfig);
    if (targetsConfig !== null) {
      config.architect = targetsConfig;
    }

    context.logger.info(`Removing old config file (${oldConfigPath})`);
    host.delete(oldConfigPath);
    context.logger.info(`Writing config file (${configPath})`);
    host.create(configPath, JSON.stringify(config, null, 2));

    return host;
  };
开发者ID:baconwaffles,项目名称:angular-cli,代码行数:34,代码来源:index.ts

示例3: return

  return (host: Tree, context: SchematicContext) => {
    if (host.exists(npmrc)) {
      host.delete(npmrc);
    }

    if (options.type === 'remove') {
      return ;
    }

    host.create(npmrc, `sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/
electron_mirror=https://npm.taobao.org/mirrors/electron/
registry=https://registry.npm.taobao.org`);
  };
开发者ID:wexz,项目名称:delon,代码行数:14,代码来源:plugin.npm.ts

示例4: overwriteFile

export function overwriteFile(
  host: Tree,
  filePath: string,
  sourcePath?: string,
  overwrite = false,
): Tree {
  const isExists = host.exists(filePath);
  if (overwrite || isExists) {
    try {
      const buffer = fs.readFileSync(sourcePath);
      const content = buffer ? buffer.toString('utf-8') : '';
      if (overwrite) {
        if (isExists) {
          host.delete(filePath);
        }
        host.create(filePath, content);
      } else {
        host.overwrite(filePath, content);
      }
    } catch {}
  }
  return host;
}
开发者ID:wexz,项目名称:delon,代码行数:23,代码来源:file.ts

示例5: return

  return (tree: Tree) => {
    const source = tree.read(polyfillPath);
    if (!source) {
      return;
    }

    // normalize line endings to increase hash match chances
    const content = source.toString().replace(/\r\n|\r/g, '\n');

    // Check if file is unmodified, if so then replace and return
    const hash = createHash('md5');
    hash.update(content);
    const digest = hash.digest('hex');
    if (knownPolyfillHashes.includes(digest)) {
      // Replace with new project polyfills file
      // This removes the need to parse and also updates all included comments

      // mergeWith overwrite doesn't work so clear out existing file
      tree.delete(polyfillPath);

      return mergeWith(
        apply(url('../../application/files/src'), [
          filter(path => path === '/polyfills.ts.template'),
          move('/polyfills.ts.template', polyfillPath),
        ]),
        MergeStrategy.Overwrite,
      );
    }

    if (!content.includes('core-js')) {
      // no action required if no mention of core-js
      return;
    }

    const sourceFile = ts.createSourceFile(polyfillPath,
      content,
      ts.ScriptTarget.Latest,
      true,
    );
    const imports = sourceFile.statements
      .filter(s => s.kind === ts.SyntaxKind.ImportDeclaration) as ts.ImportDeclaration[];

    if (imports.length === 0) { return; }

    // Start the update of the file.
    const recorder = tree.beginUpdate(polyfillPath);

    const applicationPolyfillsStart = content.indexOf(applicationPolyfillsHeader);
    const browserPolyfillsStart = content.indexOf(browserPolyfillsHeader);

    let addHeader = false;
    for (const i of imports) {
      const module = ts.isStringLiteral(i.moduleSpecifier) && i.moduleSpecifier.text;
      // We do not want to remove imports which are after the "APPLICATION IMPORTS" header.
      if (module && toDrop[module] && applicationPolyfillsStart > i.getFullStart()) {
        recorder.remove(i.getFullStart(), i.getFullWidth());
        if (i.getFullStart() <= browserPolyfillsStart) {
          addHeader = true;
        }
      }
    }

    // We've removed the header since it's part of the JSDoc of the nodes we dropped
    if (addHeader) {
      recorder.insertLeft(0, header);
    }

    tree.commitUpdate(recorder);
  };
开发者ID:angular,项目名称:angular-cli,代码行数:69,代码来源:drop-es6-polyfills.ts

示例6:

 .forEach(p => host.delete(p));
开发者ID:wexz,项目名称:delon,代码行数:1,代码来源:index.ts

示例7: tryAddFile

export function tryAddFile(host: Tree, path: string, content: string) {
  if (host.exists(path)) {
    host.delete(path);
  }
  host.create(path, content);
}
开发者ID:wexz,项目名称:delon,代码行数:6,代码来源:alain.ts

示例8: return

 return (tree: Tree, context: SchematicContext) => {
   tree.delete(options.deletePath);
   context.addTask(new RunSchematicTask('ng-post-post-update', {}));
 };
开发者ID:OkBayat,项目名称:material2,代码行数:4,代码来源:update.ts


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