Skip to content

Chain steps seem to be repeated multiple times #11267

@sebawita

Description

@sebawita

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Area

- [x] devkit
- [ ] schematics

Versions

@angular/cli@6.1.0.rc.0

Repro steps

When I run a schematic like:

let x = 1;

export default function(_options: any): Rule {
  return chain([
    () => {
      console.log(`Say it #${x++}`);
    },
    addSebastian,
    addCharles,
    addHans
  ]);
}

const addSebastian = () => {
  const templateOptions = {
    name: 'sebastian'
  };
  const templateSource = apply(url('./_files'), [
      template(templateOptions)
  ]);
  return mergeWith(templateSource);
}

const addCharles = () => {
  const templateOptions = {
    name: 'charles'
  };
  const templateSource = apply(url('./_files'), [
      template(templateOptions)
  ]);
  return mergeWith(templateSource);
}

const addHans = () => {
  const templateOptions = {
    name: 'hans'
  };
  const templateSource = apply(url('./_files'), [
      template(templateOptions)
  ]);
  return mergeWith(templateSource);
}

I get a message printed in the first step 8 times. Which suggests that the step runs 8 times.
I would expect it to be executed only once.

You can easily reproduce the issue with this project.
https://github.com/sebawita/sample

The log given by the failure

screen shot 2018-06-15 at 16 20 32

Desired functionality

I only expect Say it #1 to be displayed, but not the other 7

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions