How to use the @angular-devkit/schematics.EmptyTree function in @angular-devkit/schematics

To help you get started, we’ve selected a few @angular-devkit/schematics 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 vmware / clarity / src / schematics / src / utility / find-module_spec.ts View on Github external
it('should throw if two modules found', () => {
      try {
        host = new EmptyTree();
        findModule(host, 'foo/src/app/bar');
        throw new Error('Succeeded, should have failed');
      } catch (err) {
        expect(err.message).toMatch(/Could not find an NgModule/);
      }
    });
  });
github angular / angular-cli / packages / schematics / angular / migrations / update-8 / differential-loading_spec.ts View on Github external
beforeEach(async () => {
      tree = new UnitTestTree(new EmptyTree());
      tree = await schematicRunner
        .runExternalSchematicAsync(
          require.resolve('../../collection.json'),
          'ng-new',
          {
            name: 'migration-test',
            version: '1.2.3',
            directory: '.',
          },
          tree,
        )
        .toPromise();
      tree.overwrite(tsConfigPath, JSON.stringify(oldTsConfig, null, 2));
    });
github ngneat / transloco / schematics / src / ng-add / index.ts View on Github external
function createTranslateFiles(langs: string[], creator): HostTree {
  const treeSource = new EmptyTree();
  langs.forEach(lang => {
    creator(treeSource, lang);
  });

  return treeSource;
}
github angular / angular-cli / packages / schematics / angular / migrations / update-9 / update-server-main-file_spec.ts View on Github external
beforeEach(async () => {
      tree = new UnitTestTree(new EmptyTree());
      tree = await schematicRunner
        .runExternalSchematicAsync(
          require.resolve('../../collection.json'),
          'ng-new',
          {
            name: 'migration-test',
            version: '1.2.3',
            directory: '.',
          },
          tree,
        )
        .toPromise();
      tree = await schematicRunner
        .runExternalSchematicAsync(
          require.resolve('../../collection.json'),
          'universal',
github ngneat / transloco / schematics / src / utils / translations.ts View on Github external
export function createTranslateFiles(langs: string[], creator, path): HostTree {
  const treeSource = new EmptyTree();
  langs.forEach(lang => {
    creator(treeSource, lang, path);
  });

  return treeSource;
}
github angular / angular-cli / packages / schematics / angular / migrations / update-9 / ivy-libraries_spec.ts View on Github external
beforeEach(async () => {
      tree = new UnitTestTree(new EmptyTree());
      tree = await schematicRunner
        .runExternalSchematicAsync(
          require.resolve('../../collection.json'),
          'workspace',
          {
            name: 'migration-test',
            version: '1.2.3',
            directory: '.',
          },
          tree,
        )
        .toPromise();

      tree = await schematicRunner
        .runExternalSchematicAsync(
          require.resolve('../../collection.json'),
github angular / angular-cli / packages / schematics / angular / migrations / update-9 / update-workspace-config_spec.ts View on Github external
beforeEach(async () => {
      tree = new UnitTestTree(new EmptyTree());
      tree = await schematicRunner
        .runExternalSchematicAsync(
          require.resolve('../../collection.json'),
          'ng-new',
          {
            name: 'migration-test',
            version: '1.2.3',
            directory: '.',
          },
          tree,
        )
        .toPromise();
    });
github fossasia / susper.com / node_modules / @angular / cli / tasks / schematic-run.js View on Github external
run: function (options) {
        const { taskOptions, workingDir, emptyHost, collectionName, schematicName, logger } = options;
        const ui = this.ui;
        const packageManager = config_1.CliConfig.fromGlobal().get('packageManager');
        const engineHost = schematics_2.getEngineHost();
        engineHost.registerTaskExecutor(node_1.BuiltinTaskExecutor.NodePackage, {
            rootDirectory: workingDir,
            packageManager: packageManager === 'default' ? 'npm' : packageManager,
        });
        engineHost.registerTaskExecutor(node_1.BuiltinTaskExecutor.RepositoryInitializer, { rootDirectory: workingDir });
        const collection = schematics_2.getCollection(collectionName);
        const schematic = schematics_2.getSchematic(collection, schematicName);
        const projectRoot = !!this.project ? this.project.root : workingDir;
        const preppedOptions = prepOptions(schematic, taskOptions);
        const opts = Object.assign({}, taskOptions, preppedOptions);
        const tree = emptyHost ? new schematics_1.EmptyTree() : new schematics_1.FileSystemTree(new tools_1.FileSystemHost(workingDir));
        const host = of_1.of(tree);
        const dryRunSink = new schematics_1.DryRunSink(workingDir, opts.force);
        const fsSink = new schematics_1.FileSystemSink(workingDir, opts.force);
        let error = false;
        const loggingQueue = [];
        const modifiedFiles = [];
        dryRunSink.reporter.subscribe((event) => {
            const eventPath = event.path.startsWith('/') ? event.path.substr(1) : event.path;
            switch (event.kind) {
                case 'error':
                    const desc = event.description == 'alreadyExist' ? 'already exists' : 'does not exist.';
                    ui.writeLine(`error! ${eventPath} ${desc}.`);
                    error = true;
                    break;
                case 'update':
                    loggingQueue.push({
github angular / angular-cli / packages / schematics / angular / migrations / update-8 / drop-es6-polyfills_spec.ts View on Github external
beforeEach(async () => {
      tree = new UnitTestTree(new EmptyTree());
      tree = await schematicRunner.runExternalSchematicAsync(
        require.resolve('../../collection.json'), 'ng-new',
        {
          name: 'migration-test',
          version: '1.2.3',
          directory: '.',
        },
        tree,
      ).toPromise();
      tree.overwrite(polyfillsPath, polyfills);
    });