0

I want to create a CLI based on schematics to improve projects creation for my job and I want to scaffold an Angular Application AND an Angular Library in one command. So I tried to use externalSchematic and it works perfectly for the application but when I want to add the library using another externalSchematic, it throws an error because it cannot find the angular.json file. So I would like to know if there is a way that I can navigate (cd command equivalent) to my newly created project, please if someone has the answer ! :pray:

Here my code:

export const ngLibrary = (options: Schema): Rule =>
  chain([
    externalSchematic('@schematics/angular', 'ng-new', options),
    externalSchematic('@schematics/angular', 'library', options)
  ]);

Error:

An error occured:
Error: Path "/angular.json" does not exist.
  at HostTree.readText()

1 Answers1

0

I found a solution. Instead of navigating in the Tree, you can execute a schematic from a scope (path).

externalSchematic('@schematics/angular', 'library', options, { scope: 'my/path' });